/**
 * This mapping is borrowed from the original rudy code by Tomash
 */

module druby.cruby;

import std.conv;
import std.c.stdio;
import std.c.time;
import std.c.string;

/* D long is always 64 bits, but when the Ruby/C API mentions long, it is of
 * course referring to the C type long, the size of which is 32 bits on both
 * X86 and X86_64 under Windows, but 32 bits on X86 and 64 bits on X86_64 under
 * most other operating systems. */

alias long C_longlong;
alias ulong C_ulonglong;

version(Windows) {
  alias int C_long;
  alias uint C_ulong;
} else {
  version (X86) {
    alias int C_long;
    alias uint C_ulong;
  } else {
    alias long C_long;
    alias ulong C_ulong;
  }
}

// ripoff from PyD's python.d END ;)

/* THIS FILE GENERATED BY bcd.gen */
align(4):
const int __STDC__ = 1;
const int __cplusplus = 1;
const int __STDC_HOSTED__ = 1;
const int __GCCXML__ = 900;
const int __GCCXML_GNUC__ = 4;
const int __GCCXML_GNUC_MINOR__ = 2;
const int __GCCXML_GNUC_PATCHLEVEL__ = 1;
const int __CHAR_BIT__ = 8;
const int __WCHAR_MAX__ = 2147483647;
const int __FLT_EVAL_METHOD__ = 2;
const int __FINITE_MATH_ONLY__ = 0;
const int __GNUC_PATCHLEVEL__ = 4;
const int __DEC64_MAX_EXP__ = 384;
const int __SHRT_MAX__ = 32767;
const int __linux = 1;
const int __OPTIMIZE__ = 1;
const int __unix = 1;
const int __LDBL_MAX_EXP__ = 16384;
const int __linux__ = 1;
const int __SCHAR_MAX__ = 127;
//const int __STDC_HOSTED__ = 1;
const int __LDBL_HAS_INFINITY__ = 1;
const int __DBL_DIG__ = 15;
const int __GXX_WEAK__ = 1;
const int __unix__ = 1;
const int __DECIMAL_DIG__ = 21;
const int __gnu_linux__ = 1;
const int __LDBL_HAS_QUIET_NAN__ = 1;
const int __GNUC__ = 4;
const int __FLT_HAS_DENORM__ = 1;
const int __DBL_HAS_INFINITY__ = 1;
const int __LDBL_HAS_DENORM__ = 1;
//const int __cplusplus = 1;
const int __DEPRECATED = 1;
const int __DBL_MAX_EXP__ = 1024;
const int __GNUG__ = 4;
const int __GXX_ABI_VERSION = 1002;
const int __DBL_HAS_QUIET_NAN__ = 1;
const int __DBL_HAS_DENORM__ = 1;
const int __DEC_EVAL_METHOD__ = 2;
const int __i386 = 1;
const int __FLT_MANT_DIG__ = 24;
const int i386 = 1;
const int __i486__ = 1;
const int unix = 1;
const int __i386__ = 1;
const int __ELF__ = 1;
const int __FLT_RADIX__ = 2;
const int __LDBL_DIG__ = 18;
const int __FLT_HAS_QUIET_NAN__ = 1;
const int __FLT_MAX_10_EXP__ = 38;
const int __LONG_MAX__ = 2147483647;
const int __FLT_HAS_INFINITY__ = 1;
const int __DEC64_MANT_DIG__ = 16;
const int __DEC32_MAX_EXP__ = 96;
const int linux = 1;
const int __EXCEPTIONS = 1;
const int __LDBL_MANT_DIG__ = 64;
const int __FLT_DIG__ = 6;
const int __INT_MAX__ = 2147483647;
const int __i486 = 1;
const int __FLT_MAX_EXP__ = 128;
const int __DBL_MANT_DIG__ = 53;
const int __LDBL_MAX_10_EXP__ = 4932;
const int __DEC128_MAX_EXP__ = 6144;
const int __GNUC_MINOR__ = 2;
const int __DEC32_MANT_DIG__ = 7;
const int __DBL_MAX_10_EXP__ = 308;
//const int __STDC__ = 1;
const int __DEC128_MANT_DIG__ = 34;
const int __GNUC_GNU_INLINE__ = 1;
const int _GNU_SOURCE = 1;
//const int __builtin_types_compatible_p(x,y) = 0;
//const int __builtin_constant_p(x) = 0;
//const int __builtin_offsetof(x,y) = 0;
const char[] PACKAGE_NAME = "";
const char[] PACKAGE_TARNAME = "";
const char[] PACKAGE_VERSION = "";
const char[] PACKAGE_STRING = "";
const char[] PACKAGE_BUGREPORT = "";
const int USE_BUILTIN_FRAME_ADDRESS = 1;
const int STDC_HEADERS = 1;
const int HAVE_SYS_TYPES_H = 1;
const int HAVE_SYS_STAT_H = 1;
const int HAVE_STDLIB_H = 1;
const int HAVE_STRING_H = 1;
const int HAVE_MEMORY_H = 1;
const int HAVE_STRINGS_H = 1;
const int HAVE_INTTYPES_H = 1;
const int HAVE_STDINT_H = 1;
const int HAVE_UNISTD_H = 1;
const int _FILE_OFFSET_BITS = 64;
const int HAVE_LONG_LONG = 1;
const int HAVE_OFF_T = 1;
const int SIZEOF_INT = 4;
const int SIZEOF_SHORT = 2;
const int SIZEOF_LONG = 4;
const int SIZEOF_LONG_LONG = 8;
const int SIZEOF___INT64 = 0;
const int SIZEOF_OFF_T = 8;
const int SIZEOF_VOIDP = 4;
const int SIZEOF_FLOAT = 4;
const int SIZEOF_DOUBLE = 8;
const int SIZEOF_TIME_T = 4;
const int HAVE_PROTOTYPES = 1;
const int HAVE_STDARG_PROTOTYPES = 1;
const int HAVE_DECL_SYS_NERR = 1;
const int HAVE_LIBCRYPT = 1;
const int HAVE_LIBDL = 1;
const int HAVE_DIRENT_H = 1;
//const int STDC_HEADERS = 1;
const int HAVE_SYS_WAIT_H = 1;
//const int HAVE_STDLIB_H = 1;
//const int HAVE_STRING_H = 1;
//const int HAVE_UNISTD_H = 1;
const int HAVE_LIMITS_H = 1;
const int HAVE_SYS_FILE_H = 1;
const int HAVE_SYS_IOCTL_H = 1;
const int HAVE_SYS_SYSCALL_H = 1;
const int HAVE_FCNTL_H = 1;
const int HAVE_SYS_FCNTL_H = 1;
const int HAVE_SYS_SELECT_H = 1;
const int HAVE_SYS_TIME_H = 1;
const int HAVE_SYS_TIMES_H = 1;
const int HAVE_SYS_PARAM_H = 1;
const int HAVE_SYSCALL_H = 1;
const int HAVE_PWD_H = 1;
const int HAVE_GRP_H = 1;
const int HAVE_A_OUT_H = 1;
const int HAVE_UTIME_H = 1;
//const int HAVE_MEMORY_H = 1;
const int HAVE_SYS_RESOURCE_H = 1;
const int HAVE_NETINET_IN_SYSTM_H = 1;
const int HAVE_FLOAT_H = 1;
const int HAVE_PTHREAD_H = 1;
const int HAVE_UCONTEXT_H = 1;
const int SIZEOF_RLIM_T = 8;
const int HAVE_STRUCT_STAT_ST_BLKSIZE = 1;
const int HAVE_ST_BLKSIZE = 1;
const int HAVE_STRUCT_STAT_ST_BLOCKS = 1;
const int HAVE_ST_BLOCKS = 1;
const int HAVE_STRUCT_STAT_ST_RDEV = 1;
const int HAVE_ST_RDEV = 1;
const int HAVE_ALLOCA_H = 1;
const int HAVE_ALLOCA = 1;
const int HAVE_FSEEKO = 1;
const int HAVE_FTELLO = 1;
const int HAVE_DUP2 = 1;
const int HAVE_MEMMOVE = 1;
const int HAVE_STRCASECMP = 1;
const int HAVE_STRNCASECMP = 1;
const int HAVE_STRERROR = 1;
const int HAVE_STRFTIME = 1;
const int HAVE_STRCHR = 1;
const int HAVE_STRSTR = 1;
const int HAVE_STRTOUL = 1;
const int HAVE_CRYPT = 1;
const int HAVE_FLOCK = 1;
const int HAVE_VSNPRINTF = 1;
const int HAVE_ISNAN = 1;
const int HAVE_FINITE = 1;
const int HAVE_ISINF = 1;
const int HAVE_HYPOT = 1;
const int HAVE_ACOSH = 1;
const int HAVE_ERF = 1;
const int HAVE_FMOD = 1;
const int HAVE_KILLPG = 1;
const int HAVE_WAIT4 = 1;
const int HAVE_WAITPID = 1;
const int HAVE_SYSCALL = 1;
const int HAVE_CHROOT = 1;
const int HAVE_FSYNC = 1;
const int HAVE_GETCWD = 1;
const int HAVE_EACCESS = 1;
const int HAVE_TRUNCATE = 1;
const int HAVE_FTRUNCATE = 1;
const int HAVE_TIMES = 1;
const int HAVE_UTIMES = 1;
const int HAVE_FCNTL = 1;
const int HAVE_LOCKF = 1;
const int HAVE_LSTAT = 1;
const int HAVE_SYMLINK = 1;
const int HAVE_LINK = 1;
const int HAVE_READLINK = 1;
const int HAVE_SETITIMER = 1;
const int HAVE_SETEUID = 1;
const int HAVE_SETREUID = 1;
const int HAVE_SETRESUID = 1;
const int HAVE_SETEGID = 1;
const int HAVE_SETREGID = 1;
const int HAVE_SETRESGID = 1;
const int HAVE_PAUSE = 1;
const int HAVE_LCHOWN = 1;
const int HAVE_GETPGRP = 1;
const int HAVE_SETPGRP = 1;
const int HAVE_GETPGID = 1;
const int HAVE_SETPGID = 1;
const int HAVE_INITGROUPS = 1;
const int HAVE_GETGROUPS = 1;
const int HAVE_SETGROUPS = 1;
const int HAVE_GETPRIORITY = 1;
const int HAVE_GETRLIMIT = 1;
const int HAVE_SETRLIMIT = 1;
const int HAVE_SYSCONF = 1;
const int HAVE_GROUP_MEMBER = 1;
const int HAVE_DLOPEN = 1;
const int HAVE_SIGPROCMASK = 1;
const int HAVE_SIGACTION = 1;
const int HAVE__SETJMP = 1;
const int HAVE__LONGJMP = 1;
const int HAVE_SETSID = 1;
const int HAVE_TELLDIR = 1;
const int HAVE_SEEKDIR = 1;
const int HAVE_FCHMOD = 1;
const int HAVE_MKTIME = 1;
const int HAVE_TIMEGM = 1;
const int HAVE_GETTIMEOFDAY = 1;
const int HAVE_COSH = 1;
const int HAVE_SINH = 1;
const int HAVE_TANH = 1;
const int HAVE_ROUND = 1;
const int HAVE_SETUID = 1;
const int HAVE_SETGID = 1;
const int HAVE_SETENV = 1;
const int HAVE_UNSETENV = 1;
const int HAVE_STRUCT_TM_TM_ZONE = 1;
const int HAVE_TM_ZONE = 1;
const int HAVE_STRUCT_TM_TM_GMTOFF = 1;
const int HAVE_DAYLIGHT = 1;
const int HAVE_VAR_TIMEZONE = 1;
const int NEGATIVE_TIME_T = 1;
const int POSIX_SIGNAL = 1;
const int GETPGRP_VOID = 1;
const int SETPGRP_VOID = 1;
const int HUGE_ST_INO = 1;
const int HAVE__SC_CLK_TCK = 1;
const int STACK_GROW_DIRECTION = -1;
const int _REENTRANT = 1;
const int _THREAD_SAFE = 1;
const int HAVE_LIBPTHREAD = 1;
const int HAVE_NANOSLEEP = 1;
const int HAVE_GETCONTEXT = 1;
const int HAVE_SETCONTEXT = 1;
const int USE_ELF = 1;
const int DLEXT_MAXLEN = 3;
const char[] DLEXT = ".so";
const char[] RUBY_LIB = "/usr/lib/ruby/1.8";
const char[] RUBY_SITE_LIB = "/usr/local/lib/site_ruby";
const char[] RUBY_SITE_LIB2 = "/usr/local/lib/site_ruby/1.8";
const char[] RUBY_VENDOR_LIB = "/usr/lib/ruby/vendor_ruby";
const char[] RUBY_VENDOR_LIB2 = "/usr/lib/ruby/vendor_ruby/1.8";
const char[] RUBY_PLATFORM = "i486-linux";
const char[] RUBY_ARCHLIB = "/usr/lib/ruby/1.8/i486-linux";
const char[] RUBY_SITE_ARCHLIB = "/usr/local/lib/site_ruby/1.8/i486-linux";
const char[] RUBY_VENDOR_ARCHLIB = "/usr/lib/ruby/vendor_ruby/1.8/i486-linux";
const char[] RUBY_EXTRA_SITE_SEARCH_PATH = "/usr/local/lib/site_ruby/1.8/i386-linux";
const char[] RUBY_EXTRA_SEARCH_PATH = "/usr/lib/ruby/1.8/i386-linux";
const int NORETURN_STYLE_NEW = 1;
alias SIZEOF_INT SIZEOF_BDIGITS;
const char[] PATH_SEP = ":";
const char[] PATH_ENV = "PATH";
const int CASEFOLD_FILESYSTEM = 0;
const int _FEATURES_H = 1;
const int __USE_ANSI = 1;
const int _ISOC99_SOURCE = 1;
const int _POSIX_SOURCE = 1;
const int _POSIX_C_SOURCE = 200112;
const int _XOPEN_SOURCE = 600;
const int _XOPEN_SOURCE_EXTENDED = 1;
const int _LARGEFILE64_SOURCE = 1;
const int _BSD_SOURCE = 1;
const int _SVID_SOURCE = 1;
const int _ATFILE_SOURCE = 1;
const int __USE_ISOC99 = 1;
const int __USE_ISOC95 = 1;
const int __USE_POSIX = 1;
const int __USE_POSIX2 = 1;
const int __USE_POSIX199309 = 1;
const int __USE_POSIX199506 = 1;
const int __USE_XOPEN2K = 1;
const int __USE_XOPEN = 1;
const int __USE_XOPEN_EXTENDED = 1;
const int __USE_UNIX98 = 1;
const int _LARGEFILE_SOURCE = 1;
//const int __USE_XOPEN2K = 1;
//const int __USE_ISOC99 = 1;
const int __USE_LARGEFILE = 1;
const int __USE_LARGEFILE64 = 1;
const int __USE_FILE_OFFSET64 = 1;
const int __USE_MISC = 1;
const int __USE_BSD = 1;
const int __USE_SVID = 1;
const int __USE_ATFILE = 1;
const int __USE_GNU = 1;
const int __USE_REENTRANT = 1;
const int __USE_FORTIFY_LEVEL = 0;
const int __STDC_IEC_559__ = 1;
const int __STDC_IEC_559_COMPLEX__ = 1;
const int __STDC_ISO_10646__ = 200009;
const int __GNU_LIBRARY__ = 6;
const int __GLIBC__ = 2;
const int __GLIBC_MINOR__ = 8;
const int __GLIBC_HAVE_LONG_LONG = 1;
const int _SYS_CDEFS_H = 1;
const int __WORDSIZE = 32;
//const int __WORDSIZE = 32;
const int _STDLIB_H = 1;
const int WNOHANG = 1;
const int WUNTRACED = 2;
const int WSTOPPED = 2;
const int WEXITED = 4;
const int WCONTINUED = 8;
const int WNOWAIT = 0x01000000;
const int __WNOTHREAD = 0x20000000;
const int __WALL = 0x40000000;
const int __WCLONE = 0x80000000;
const int __W_CONTINUED = 0xffff;
const int __WCOREFLAG = 0x80;
const int _ENDIAN_H = 1;
const int __LITTLE_ENDIAN = 1234;
const int __BIG_ENDIAN = 4321;
const int __PDP_ENDIAN = 3412;
alias __LITTLE_ENDIAN __BYTE_ORDER;
alias __BYTE_ORDER __FLOAT_WORD_ORDER;
alias __LITTLE_ENDIAN LITTLE_ENDIAN;
alias __BIG_ENDIAN BIG_ENDIAN;
alias __PDP_ENDIAN PDP_ENDIAN;
alias __BYTE_ORDER BYTE_ORDER;
const int __ldiv_t_defined = 1;
const int __lldiv_t_defined = 1;
const int RAND_MAX = 2147483647;
const int EXIT_FAILURE = 1;
const int EXIT_SUCCESS = 0;
const int _XLOCALE_H = 1;
const int _SYS_TYPES_H = 1;
const int _BITS_TYPES_H = 1;
//const int __WORDSIZE = 32;
const int _BITS_TYPESIZES_H = 1;
const int __FD_SETSIZE = 1024;
const int __clock_t_defined = 1;
const int __time_t_defined = 1;
const int __clockid_t_defined = 1;
const int __timer_t_defined = 1;
const int __BIT_TYPES_DEFINED__ = 1;
const int _SYS_SELECT_H = 1;
const int _SIGSET_H_types = 1;
const int __timespec_defined = 1;
const int _STRUCT_TIMEVAL = 1;
alias __FD_SETSIZE FD_SETSIZE;
const int _SYS_SYSMACROS_H = 1;
const int _BITS_PTHREADTYPES_H = 1;
//const int __WORDSIZE = 32;
const int __SIZEOF_PTHREAD_ATTR_T = 36;
const int __SIZEOF_PTHREAD_MUTEX_T = 24;
const int __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
const int __SIZEOF_PTHREAD_COND_T = 48;
const int __SIZEOF_PTHREAD_CONDATTR_T = 4;
const int __SIZEOF_PTHREAD_RWLOCK_T = 32;
const int __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
const int __SIZEOF_PTHREAD_BARRIER_T = 20;
const int __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
const int _ALLOCA_H = 1;
const int _STRING_H = 1;
const int _STDIO_H = 1;
const int __FILE_defined = 1;
const int ____FILE_defined = 1;
const int _G_config_h = 1;
const int __mbstate_t_defined = 1;
const int _G_HAVE_BOOL = 1;
const int _G_HAVE_ATEXIT = 1;
const int _G_HAVE_SYS_CDEFS = 1;
const int _G_HAVE_SYS_WAIT = 1;
const int _G_NEED_STDARG_H = 1;
const int _G_HAVE_PRINTF_FP = 1;
const int _G_HAVE_MMAP = 1;
const int _G_HAVE_MREMAP = 1;
const int _G_HAVE_LONG_DOUBLE_IO = 1;
const int _G_HAVE_IO_FILE_OPEN = 1;
const int _G_HAVE_IO_GETLINE_INFO = 1;
const int _G_IO_IO_FILE_VERSION = 0x20001;
const int _G_BUFSIZ = 8192;
const int _G_NAMES_HAVE_UNDERSCORE = 0;
const int _G_VTABLE_LABEL_HAS_LENGTH = 1;
const int _G_USING_THUNKS = 1;
const char[] _G_VTABLE_LABEL_PREFIX = "__vt_";
alias _G_HAVE_SYS_WAIT _IO_HAVE_SYS_WAIT;
alias _G_BUFSIZ _IO_BUFSIZ;
const int _IO_UNIFIED_JUMPTABLES = 1;
const int _IOS_INPUT = 1;
const int _IOS_OUTPUT = 2;
const int _IOS_ATEND = 4;
const int _IOS_APPEND = 8;
const int _IOS_TRUNC = 16;
const int _IOS_NOCREATE = 32;
const int _IOS_NOREPLACE = 64;
const int _IOS_BIN = 128;
const int _IO_MAGIC = 0xFBAD0000;
const int _OLD_STDIO_MAGIC = 0xFABC0000;
const int _IO_MAGIC_MASK = 0xFFFF0000;
const int _IO_USER_BUF = 1;
const int _IO_UNBUFFERED = 2;
const int _IO_NO_READS = 4;
const int _IO_NO_WRITES = 8;
const int _IO_EOF_SEEN = 0x10;
const int _IO_ERR_SEEN = 0x20;
const int _IO_DELETE_DONT_CLOSE = 0x40;
const int _IO_LINKED = 0x80;
const int _IO_IN_BACKUP = 0x100;
const int _IO_LINE_BUF = 0x200;
const int _IO_TIED_PUT_GET = 0x400;
const int _IO_CURRENTLY_PUTTING = 0x800;
const int _IO_IS_APPENDING = 0x1000;
const int _IO_IS_FILEBUF = 0x2000;
const int _IO_BAD_SEEN = 0x4000;
const int _IO_USER_LOCK = 0x8000;
const int _IO_FLAGS2_MMAP = 1;
const int _IO_FLAGS2_NOTCANCEL = 2;
const int _IO_FLAGS2_USER_WBUF = 8;
const int _IO_SKIPWS = std.conv.octal!1;
const int _IO_LEFT = std.conv.octal!2;
const int _IO_RIGHT = std.conv.octal!4;
const int _IO_INTERNAL = std.conv.octal!10;
const int _IO_DEC = std.conv.octal!20;
const int _IO_OCT = std.conv.octal!40;
const int _IO_HEX = std.conv.octal!100;
const int _IO_SHOWBASE = std.conv.octal!200;
const int _IO_SHOWPOINT = std.conv.octal!400;
const int _IO_UPPERCASE = std.conv.octal!1000;
const int _IO_SHOWPOS = std.conv.octal!2000;
const int _IO_SCIENTIFIC = std.conv.octal!4000;
const int _IO_FIXED = std.conv.octal!10000;
const int _IO_UNITBUF = std.conv.octal!20000;
const int _IO_STDIO = std.conv.octal!40000;
const int _IO_DONT_CLOSE = std.conv.octal!100000;
const int _IO_BOOLALPHA = std.conv.octal!200000;
const int _IOFBF = 0;
const int _IOLBF = 1;
const int _IONBF = 2;
alias _IO_BUFSIZ BUFSIZ;
const int SEEK_SET = 0;
const int SEEK_CUR = 1;
const int SEEK_END = 2;
const char[] P_tmpdir = "/tmp";
const int L_tmpnam = 20;
const int TMP_MAX = 238328;
const int FILENAME_MAX = 4096;
const int L_ctermid = 9;
const int L_cuserid = 9;
const int FOPEN_MAX = 16;
const int _LIBC_LIMITS_H_ = 1;
const int MB_LEN_MAX = 16;
const int _BITS_POSIX1_LIM_H = 1;
const int _POSIX_AIO_LISTIO_MAX = 2;
const int _POSIX_AIO_MAX = 1;
const int _POSIX_ARG_MAX = 4096;
const int _POSIX_CHILD_MAX = 25;
const int _POSIX_DELAYTIMER_MAX = 32;
const int _POSIX_HOST_NAME_MAX = 255;
const int _POSIX_LINK_MAX = 8;
const int _POSIX_LOGIN_NAME_MAX = 9;
const int _POSIX_MAX_CANON = 255;
const int _POSIX_MAX_INPUT = 255;
const int _POSIX_MQ_OPEN_MAX = 8;
const int _POSIX_MQ_PRIO_MAX = 32;
const int _POSIX_NAME_MAX = 14;
const int _POSIX_NGROUPS_MAX = 8;
const int _POSIX_OPEN_MAX = 20;
alias _POSIX_OPEN_MAX _POSIX_FD_SETSIZE;
const int _POSIX_PATH_MAX = 256;
const int _POSIX_PIPE_BUF = 512;
const int _POSIX_RE_DUP_MAX = 255;
const int _POSIX_RTSIG_MAX = 8;
const int _POSIX_SEM_NSEMS_MAX = 256;
const int _POSIX_SEM_VALUE_MAX = 32767;
const int _POSIX_SIGQUEUE_MAX = 32;
const int _POSIX_SSIZE_MAX = 32767;
const int _POSIX_STREAM_MAX = 8;
const int _POSIX_SYMLINK_MAX = 255;
const int _POSIX_SYMLOOP_MAX = 8;
const int _POSIX_TIMER_MAX = 32;
const int _POSIX_TTY_NAME_MAX = 9;
const int _POSIX_TZNAME_MAX = 6;
const int _POSIX_QLIMIT = 1;
alias _POSIX_PIPE_BUF _POSIX_HIWAT;
const int _POSIX_UIO_MAXIOV = 16;
const int _POSIX_CLOCKRES_MIN = 20000000;
const int NR_OPEN = 1024;
const int NGROUPS_MAX = 65536;
const int ARG_MAX = 131072;
const int LINK_MAX = 127;
const int MAX_CANON = 255;
const int MAX_INPUT = 255;
const int NAME_MAX = 255;
const int PATH_MAX = 4096;
const int PIPE_BUF = 4096;
const int XATTR_NAME_MAX = 255;
const int XATTR_SIZE_MAX = 65536;
const int XATTR_LIST_MAX = 65536;
const int RTSIG_MAX = 32;
const int _POSIX_THREAD_KEYS_MAX = 128;
const int PTHREAD_KEYS_MAX = 1024;
const int _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4;
alias _POSIX_THREAD_DESTRUCTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS;
const int _POSIX_THREAD_THREADS_MAX = 64;
const int AIO_PRIO_DELTA_MAX = 20;
const int PTHREAD_STACK_MIN = 16384;
const int DELAYTIMER_MAX = 2147483647;
const int TTY_NAME_MAX = 32;
const int LOGIN_NAME_MAX = 256;
const int HOST_NAME_MAX = 64;
const int MQ_PRIO_MAX = 32768;
const int _BITS_POSIX2_LIM_H = 1;
const int _POSIX2_BC_BASE_MAX = 99;
const int _POSIX2_BC_DIM_MAX = 2048;
const int _POSIX2_BC_SCALE_MAX = 99;
const int _POSIX2_BC_STRING_MAX = 1000;
const int _POSIX2_COLL_WEIGHTS_MAX = 2;
const int _POSIX2_EXPR_NEST_MAX = 32;
const int _POSIX2_LINE_MAX = 2048;
const int _POSIX2_RE_DUP_MAX = 255;
const int _POSIX2_CHARCLASS_NAME_MAX = 14;
alias _POSIX2_BC_BASE_MAX BC_BASE_MAX;
alias _POSIX2_BC_DIM_MAX BC_DIM_MAX;
alias _POSIX2_BC_SCALE_MAX BC_SCALE_MAX;
alias _POSIX2_BC_STRING_MAX BC_STRING_MAX;
const int COLL_WEIGHTS_MAX = 255;
alias _POSIX2_EXPR_NEST_MAX EXPR_NEST_MAX;
alias _POSIX2_LINE_MAX LINE_MAX;
const int CHARCLASS_NAME_MAX = 2048;
const int _XOPEN_LIM_H = 1;
//const int L_tmpnam = 20;
//const int TMP_MAX = 238328;
//const int FILENAME_MAX = 4096;
//const int L_ctermid = 9;
//const int L_cuserid = 9;
//const int FOPEN_MAX = 16;
const int IOV_MAX = 1024;
alias _POSIX_UIO_MAXIOV _XOPEN_IOV_MAX;
alias _POSIX_ARG_MAX NL_ARGMAX;
alias _POSIX2_LINE_MAX NL_LANGMAX;
const int NZERO = 20;
const int WORD_BIT = 32;
const int LONG_BIT = 32;
alias __CHAR_BIT__ CHAR_BIT;
alias __SCHAR_MAX__ SCHAR_MAX;
alias SCHAR_MAX CHAR_MAX;
alias __SHRT_MAX__ SHRT_MAX;
alias __INT_MAX__ INT_MAX;
alias __LONG_MAX__ LONG_MAX;
const int FIXNUM_FLAG = 0x01;

const int IMMEDIATE_MASK = 0x03;
VALUE IMMEDIATE_P(VALUE x)
{
  return (x & IMMEDIATE_MASK);
}

const int SYMBOL_FLAG = 0x0e;
VALUE SYMBOL_P(VALUE x)
{
  return ((x & 0xff) == SYMBOL_FLAG);
}
//#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
//#define SYM2ID(x) RSHIFT((unsigned long)x,8)


const int T_NONE = 0x00;
const int T_NIL = 0x01;
const int T_OBJECT = 0x02;
const int T_CLASS = 0x03;
const int T_ICLASS = 0x04;
const int T_MODULE = 0x05;
const int T_FLOAT = 0x06;
const int T_STRING = 0x07;
const int T_REGEXP = 0x08;
const int T_ARRAY = 0x09;
const int T_FIXNUM = 0x0a;
const int T_HASH = 0x0b;
const int T_STRUCT = 0x0c;
const int T_BIGNUM = 0x0d;
const double T_FILE = 0x0e;
const int T_TRUE = 0x20;
const int T_FALSE = 0x21;
const int T_DATA = 0x22;
const int T_MATCH = 0x23;
const int T_SYMBOL = 0x24;
const int T_BLKTAG = 0x3b;
const int T_UNDEF = 0x3c;
const int T_VARMAP = 0x3d;
const double T_SCOPE = 0x3e;
const int T_NODE = 0x3f;
const int T_MASK = 0x3f;
const int FL_USHIFT = 11;
const int _SYS_TIME_H = 1;
const int ID_ALLOCATOR = 1;
const int HAVE_RB_DEFINE_ALLOC_FUNC = 1;
const int RB_CVAR_SET_4ARGS = 1;
const int _PTHREAD_H = 1;
const int _SCHED_H = 1;
const int SCHED_OTHER = 0;
const int SCHED_FIFO = 1;
const int SCHED_RR = 2;
const int SCHED_BATCH = 3;
const int CSIGNAL = 0x000000ff;
const int CLONE_VM = 0x00000100;
const int CLONE_FS = 0x00000200;
const int CLONE_FILES = 0x00000400;
const int CLONE_SIGHAND = 0x00000800;
const int CLONE_PTRACE = 0x00002000;
const int CLONE_VFORK = 0x00004000;
const int CLONE_PARENT = 0x00008000;
const int CLONE_THREAD = 0x00010000;
const int CLONE_NEWNS = 0x00020000;
const int CLONE_SYSVSEM = 0x00040000;
const int CLONE_SETTLS = 0x00080000;
const int CLONE_PARENT_SETTID = 0x00100000;
const int CLONE_CHILD_CLEARTID = 0x00200000;
const int CLONE_DETACHED = 0x00400000;
const int CLONE_UNTRACED = 0x00800000;
const int CLONE_CHILD_SETTID = 0x01000000;
const int CLONE_NEWUTS = 0x04000000;
const int CLONE_NEWIPC = 0x08000000;
const int CLONE_NEWUSER = 0x10000000;
const int CLONE_NEWPID = 0x20000000;
const int CLONE_NEWNET = 0x40000000;
const int CLONE_IO = 0x80000000;
const int __defined_schedparam = 1;
const int __CPU_SETSIZE = 1024;
alias __CPU_SETSIZE CPU_SETSIZE;
const int _TIME_H = 1;
const int _BITS_TIME_H = 1;
const int CLOCK_REALTIME = 0;
const int CLOCK_MONOTONIC = 1;
const int CLOCK_PROCESS_CPUTIME_ID = 2;
const int CLOCK_THREAD_CPUTIME_ID = 3;
const int TIMER_ABSTIME = 1;
const int _BITS_SETJMP_H = 1;
//const int __WORDSIZE = 32;
//const int __WORDSIZE = 32;
const int PTHREAD_ONCE_INIT = 0;
const int PTHREAD_BARRIER_SERIAL_THREAD = -1;
alias int __time_t;
alias int __suseconds_t;
alias int __blksize_t;
alias int blksize_t;
alias int __swblk_t;
alias long __quad_t;
alias long __blkcnt64_t;
alias long blkcnt64_t;
alias uint __cpu_mask;
alias void _IO_lock_t;
alias uint __u_int;
alias uint u_int;
alias uint VALUE;
//typedef uint VALUE;

alias ulong __uint64_t;
alias uint __id_t;
alias int time_t;
alias int __clock_t;
alias int clock_t;
alias int __sig_atomic_t;
alias int __intptr_t;
alias _IO_FILE __FILE;
alias uint function(uint, uint) _BCD_func__174;
alias _BCD_func__174 rb_block_call_func;
alias int __clockid_t;
alias int clockid_t;
alias ulong __u_quad_t;
alias ulong __fsblkcnt64_t;
alias ulong fsblkcnt64_t;
alias uint __socklen_t;
alias short __int16_t;
alias long __off64_t;
alias long __loff_t;
alias short _G_int16_t;
alias ulong __rlim64_t;
alias uint __useconds_t;
alias uint useconds_t;
alias long off_t;
alias int function(void *) _BCD_func__256;
alias _BCD_func__256 __io_close_fn;
alias __sigset_t sigset_t;
alias char __u_char;
alias char u_char;
alias _IO_cookie_io_functions_t cookie_io_functions_t;
alias ushort __uint16_t;
alias ushort _G_uint16_t;
alias __pthread_internal_slist __pthread_slist_t;
alias int __ssize_t;
alias uint size_t;
alias int function(void *, char *, uint) _BCD_func__335;
alias _BCD_func__335 __io_write_fn;
alias _BCD_func__335 cookie_write_function_t;
alias ushort __u_short;
alias uint __uid_t;
alias uint uid_t;
alias uint uint_;
alias int pthread_spinlock_t;
alias uint __mode_t;
alias uint __gid_t;
alias uint gid_t;
alias char * __gnuc_va_list;
alias char * va_list;
alias void * __timer_t;
alias void * timer_t;
alias int _G_int32_t;
alias int __off_t;
alias char u_int8_t;
alias __fsid_t fsid_t;
alias char __int8_t;
alias int function(void *, void *, void *) _BCD_func__1691;
alias _BCD_func__1691 __compar_d_fn_t;
alias ushort u_short;
alias ulong __fsfilcnt64_t;
alias ulong fsfilcnt_t;
alias _G_fpos64_t fpos64_t;
alias int int32_t;
alias uint __ino_t;
alias long quad_t;
alias uint __u_long;
alias uint u_long;
alias uint u_int32_t;
alias int [6] __jmp_buf;
alias int __pid_t;
alias void function(void *) _BCD_func__1707;
alias _BCD_func__1707 RUBY_DATA_FUNC;
alias ulong __dev_t;
enum __itimer_which {
ITIMER_REAL=0,
ITIMER_VIRTUAL=1,
ITIMER_PROF=2,
}
alias long blkcnt_t;
alias ulong fsblkcnt_t;
alias uint __uint32_t;
//alias 4__38 __pthread_unwind_buf_t;
alias ulong __ino64_t;
alias ulong ino64_t;
alias int function(void *, char *, uint) _BCD_func__715;
alias _BCD_func__715 __io_read_fn;
alias _BCD_func__715 cookie_read_function_t;
alias short int16_t;
alias int __daddr_t;
alias uint ulong_;
alias int ptrdiff_t;
alias uint __fsfilcnt_t;
alias int __blkcnt_t;
alias _IO_FILE FILE;
alias ulong fsfilcnt64_t;
alias int __fd_mask;
alias int suseconds_t;
alias uint pthread_t;
alias uint rb_nativethread_t;
alias int pid_t;
alias int daddr_t;
alias int ssize_t;
alias long __int64_t;
alias uint __fsblkcnt_t;
//extern (C) void This->__setdoit(void *This, int);
//extern (C) void This->__defer(void *This);
//extern (C) void This->__restore(void *This);
alias long loff_t;
alias int function(void *, void *) _BCD_func__1775;
alias _BCD_func__1775 __compar_fn_t;
alias int function(void *, long *, int) _BCD_func__996;
alias _BCD_func__996 __io_seek_fn;
alias char __uint8_t;
alias __locale_struct * __locale_t;
alias int __key_t;
alias long int64_t;
alias ulong u_int64_t;
alias int register_t;
alias uint __nlink_t;
alias ushort u_int16_t;
alias uint mode_t;
alias _BCD_func__996 cookie_seek_function_t;
alias int function(char *, uint) _BCD_func__1144;
alias _BCD_func__1144 ruby_glob_func;
alias uint id_t;
alias uint pthread_key_t;
alias uint _G_uint32_t;
alias ulong u_quad_t;
alias char int8_t;
alias _G_fpos64_t fpos_t;
alias int __itimer_which_t;
alias uint ID;
alias uint nlink_t;
alias int pthread_once_t;
alias char * __caddr_t;
alias char * caddr_t;
alias long * __qaddr_t;
alias int fd_mask;
alias timezone * __timezone_ptr_t;
enum __codecvt_result {
__codecvt_ok=0,
__codecvt_partial=1,
__codecvt_error=2,
__codecvt_noconv=3,
}
alias ulong ino_t;
alias long off64_t;
alias int key_t;
alias uint __rlim_t;
alias _BCD_func__256 cookie_close_function_t;
alias ushort ushort_;
alias _BCD_func__1775 comparison_fn_t;
alias ulong dev_t;
alias int __int32_t;
extern (C) char * rindex(char *, int);
extern (C) uint rb_funcall3(uint, uint, int, uint *);
extern (C) int pthread_getschedparam(uint, int *, sched_param *);
extern (C) void rb_thread_signal_exit();
extern (C) char * rb_source_filename(char *);
extern (C) uint rb_big_divmod(uint, uint);
alias int function(...) _BCD_func__1836;
extern (C) void st_foreach_safe(void *, _BCD_func__1836, uint);
extern (C) int pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *);
extern (C) uint rb_num_coerce_relop(uint, uint);
extern (C) _IO_FILE * tmpfile();
extern (C) void rb_trap_exec();
extern (C) double drand48();
extern (C) uint rb_funcall2(uint, uint, int, uint *);
extern (C) int sched_yield();
extern (C) int vprintf(char *, char *);
extern (C) int remove(char *);
extern (C) void rb_load_file(char *);
extern (C) uint rb_str_new(char *, int);
extern (C) int wctomb(char *, wchar);
extern (C) void rb_backtrace();
extern (C) uint rb_tainted_str_new2(char *);
extern (C) int pthread_mutex_lock(pthread_mutex_t *);
extern (C) void * rb_mod_const_of(uint, void *);
extern (C) real strtold_l(char *, char * *, __locale_struct *);
extern (C) int pthread_mutexattr_setrobust_np(pthread_mutexattr_t *, int);
extern (C) uint rb_lastline_get();
extern (C) void rb_thread_interrupt();
extern (C) uint rb_class_name(uint);
extern (C) void rb_gc_force_recycle(uint);
extern (C) char * realpath(char *, char *);
extern (C) void bzero(void *, uint);
extern (C) void rb_warning(char *, ...);
extern (C) void rb_extend_object(uint, uint);
extern (C) void rb_trap_exit();
extern (C) int ruby_stack_check();
extern (C) int fseeko64(_IO_FILE *, long, int);
extern (C) _IO_FILE * popen(char *, char *);
extern (C) void rb_name_class(uint, uint);
extern (C) int pthread_cond_destroy(pthread_cond_t *);
extern (C) int fgetc_unlocked(_IO_FILE *);
extern (C) int renameat(int, char *, int, char *);
extern (C) uint rb_ary_sort_bang(uint);
extern (C) long ftello(_IO_FILE *);
extern (C) void ruby_init();
extern (C) int rb_cmpint(uint, uint, uint);
extern (C) int rb_provided(char *);
extern (C) void rb_loaderror(char *, ...);
alias uint function(...) _BCD_func__1839;
extern (C) uint rb_block_call(uint, uint, int, uint *, _BCD_func__1839, uint);
extern (C) int vsnprintf(char *, uint, char *, char *);
extern (C) void setbuf(_IO_FILE *, char *);

extern (C) VALUE rb_str_to_str(VALUE);
extern (C) uint rb_str_intern(VALUE);
extern (C) uint rb_string_value(VALUE*);
extern (C) char *rb_string_value_ptr(VALUE*);
extern (C) char *rb_string_value_cstr(VALUE*);

VALUE StringValue(VALUE obj)
{
  return rb_string_value(&obj);
}
char* StringValuePtr(VALUE obj)
{
  return rb_string_value_ptr(&obj);
}
char* StringValueCStr(VALUE obj)
{
  return rb_string_value_cstr(&obj);
}

//(of course) obj here is a pointer to RString struct, not an actual integer
//using struct and struct*: this is transparent to the programmer, as in D syntactic is the same (struct.field)

//template equivalent of:
//#define R_CAST(st)   (struct st*)
T* RCAST(T)(VALUE obj) {
  return cast(T*)obj;
}

alias RCAST!(RBasic) RBASIC;
alias RCAST!(RObject) ROBJECT;
alias RCAST!(RClass) RCLASS;
alias RCLASS RMODULE;
alias RCAST!(RFloat) RFLOAT;
alias RCAST!(RString) RSTRING;
alias RCAST!(RRegexp) RREGEXP;
alias RCAST!(RArray) RARRAY;
alias RCAST!(RHash) RHASH;
alias RCAST!(RData) RDATA;
alias RCAST!(RStruct) RSTRUCT;
alias RCAST!(RBignum) RBIGNUM;
alias RCAST!(RFile) RFILE;

/*RString StringValue(uint obj)
{
  VALUE tmp = rb_string_value(&obj);
  RString* str_struct = cast(RString*)tmp;
  return *str_struct;
}*/

extern (C) uint rb_hash_freeze(uint);
extern (C) uint rb_eval_string_wrap(char *, int *);
extern (C) uint rb_dvar_defined(uint);
extern (C) void rb_define_attr(uint, char *, int, int);
extern (C) uint rb_length_by_each(uint);
extern (C) uint rb_thread_wakeup(uint);
extern (C) int obstack_vprintf(void *, char *, char *);
extern (C) int fflush(_IO_FILE *);
extern (C) uint rb_obj_taint(uint);
extern (C) double difftime(int, int);
extern (C) uint rb_ary_rassoc(uint, uint);
alias void function(char *, uint) _BCD_func__1845;
extern (C) void rb_globi(char *, _BCD_func__1845, uint);
extern (C) uint rb_require(char *);
extern (C) void rb_define_singleton_method(uint, char *, _BCD_func__1839, int);
extern (C) void _IO_flockfile(_IO_FILE *);
extern (C) int ffsl(int);
extern (C) void rb_thread_signal_raise(int);
extern (C) int putc_unlocked(int, _IO_FILE *);
extern (C) int asprintf(char * *, char *, ...);
extern (C) int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *);
extern (C) uint rb_mod_constants(uint);
extern (C) uint rb_define_module_under(uint, char *);
extern (C) double rb_num2dbl(uint);
extern (C) int mkstemp(char *);
extern (C) int strcasecmp(char *, char *);
extern (C) int pthread_attr_setscope(pthread_attr_t *, int);
extern (C) uint rb_ary_sort(uint);
extern (C) uint rb_big_xor(uint, uint);
extern (C) uint rb_dvar_curr(uint);
extern (C) uint rb_str_upto(uint, uint, int);
extern (C) uint rb_obj_alloc(uint);
extern (C) int pthread_condattr_setpshared(pthread_condattr_t *, int);
extern (C) uint rb_big_mul(uint, uint);
extern (C) int ruby_globi(char *, int, _BCD_func__1144, uint);
alias void * function(void *) _BCD_func__1850;
extern (C) int pthread_create(uint *, pthread_attr_t *, _BCD_func__1850, void *);
extern (C) uint rb_str_format(int, uint *, uint);
extern (C) uint rb_obj_dup(uint);
extern (C) uint rb_ary_delete(uint, uint);
extern (C) uint rb_yield_values(int, ...);
extern (C) double atof(char *);
extern (C) int atoi(char *);
extern (C) uint rb_mod_remove_cvar(uint, uint);
extern (C) int vsscanf(char *, char *, char *);
extern (C) void rb_thread_wait_fd(int);
extern (C) int pthread_condattr_getclock(pthread_condattr_t *, int *);
extern (C) void rb_compile_error(char *, ...);
extern (C) uint rb_mod_include_p(uint, uint);
extern (C) long ftello64(_IO_FILE *);
extern (C) uint rb_data_object_alloc(uint, void *, _BCD_func__1707, _BCD_func__1707);
extern (C) void rb_warn(char *, ...);
extern (C) uint rb_reg_match2(uint);
extern (C) uint rb_obj_id(uint);
extern (C) void rb_thread_sleep_forever();
extern (C) int grantpt(int);
extern (C) uint rb_obj_init_copy(uint, uint);
extern (C) void setlinebuf(_IO_FILE *);
extern (C) int timegm(tm *);
extern (C) int setstate_r(char *, random_data *);
extern (C) uint rb_gv_get(char *);
extern (C) void rb_sys_fail(char *);
extern (C) int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int);
extern (C) uint rb_thread_run(uint);
extern (C) int __underflow(_IO_FILE *);
extern (C) uint rb_hash_delete_if(uint);
extern (C) int rb_is_instance_id(uint);
extern (C) uint rb_mod_module_eval(int, uint *, uint);
extern (C) char * rb_str2cstr(uint, int *);
extern (C) uint rb_f_abort(int, uint *);
extern (C) int fcloseall();
extern (C) int pthread_mutexattr_getpshared(pthread_mutexattr_t *, int *);
extern (C) void rb_parser_while_loop(int, int);
extern (C) long llabs(long);
extern (C) int setvbuf(_IO_FILE *, char *, int, uint);
extern (C) void rb_gc_mark_threads();
extern (C) void rb_need_block();
extern (C) void bcopy(void *, void *, uint);
extern (C) uint rb_rescue(_BCD_func__1839, uint, _BCD_func__1839, uint);
extern (C) _IO_FILE * fopen64(char *, char *);
extern (C) int pthread_attr_init(pthread_attr_t *);
extern (C) int rb_waitpid(int, int *, int);
extern (C) uint rb_str_freeze(uint);
extern (C) uint rb_ary_print_on(uint, uint);
extern (C) int sprintf(char *, char *, ...);
extern (C) void _Exit(int);
extern (C) int fgetpos64(_IO_FILE *, _G_fpos64_t *);
extern (C) int pthread_mutexattr_destroy(pthread_mutexattr_t *);
extern (C) double strtod(char *, char * *);
extern (C) float strtof(char *, char * *);
extern (C) int strtol(char *, char * *, int);
extern (C) uint rb_marshal_dump(uint, uint);
extern (C) void rb_thread_trap_eval(uint, int, int);
extern (C) _IO_FILE * fmemopen(void *, uint, char *);
extern (C) int putchar(int);
extern (C) uint rb_path2class(char *);
extern (C) uint wcstombs(char *, wchar *, uint);
extern (C) int posix_openpt(int);
alias void function(...) _BCD_func__1858;
extern (C) void rb_define_virtual_variable(char *, _BCD_func__1839, _BCD_func__1858);
extern (C) int pthread_spin_trylock(int *);
extern (C) int pthread_mutex_timedlock(pthread_mutex_t *, timespec *);
extern (C) void rb_define_hooked_variable(char *, uint *, _BCD_func__1839, _BCD_func__1858);
extern (C) uint rb_mod_ancestors(uint);
extern (C) int getc(_IO_FILE *);
extern (C) char * gets(char *);
extern (C) int getw(_IO_FILE *);
extern (C) void funlockfile(_IO_FILE *);
extern (C) int setitimer(int, itimerval *, itimerval *);
extern (C) int rb_const_defined_at(uint, uint);
//extern (C) void rb_define_module_function(uint, char *, _BCD_func__1839, int);
extern (C) void rb_define_module_function(uint, char *, VALUE function (), int);
extern (C) int feof_unlocked(_IO_FILE *);
extern (C) int jrand48(ushort *);
extern (C) int printf(char *, ...);
extern (C) uint rb_hash_aref(uint, uint);
extern (C) uint rb_make_metaclass(uint, uint);
extern (C) uint rb_str_associated(uint);
extern (C) void rb_mark_tbl(void *);
extern (C) int pthread_join(uint, void * *);
extern (C) int __asprintf(char * *, char *, ...);
extern (C) void rb_num_zerodiv();
extern (C) void qsort(void *, uint, uint, _BCD_func__1775);
extern (C) uint rb_ary_to_ary(uint);
extern (C) void rb_p(uint);
extern (C) uint rb_gc_start();
extern (C) int clearenv();
extern (C) _IO_FILE * tmpfile64();
extern (C) char * mkdtemp(char *);
extern (C) int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
extern (C) int pthread_mutex_getprioceiling(pthread_mutex_t *, int *);
extern (C) float strtof_l(char *, char * *, __locale_struct *);
extern (C) uint rb_num_coerce_bin(uint, uint);
extern (C) int fseek(_IO_FILE *, int, int);
extern (C) char * ptsname(int);
extern (C) uint rb_ary_each(uint);
extern (C) int rb_memcicmp(void *, void *, int);
extern (C) int rb_num2long(uint);
extern (C) tm * gmtime(int *);
extern (C) int getchar();
extern (C) int mrand48_r(drand48_data *, int *);
extern (C) void * memchr(void *, int, uint);
extern (C) int fseeko(_IO_FILE *, long, int);
extern (C) int pthread_attr_setschedparam(pthread_attr_t *, sched_param *);
extern (C) void rb_thread_start_timer();
extern (C) void clearerr(_IO_FILE *);
extern (C) char * qecvt(real, int, int *, int *);
extern (C) uint fwrite_unlocked(void *, uint, uint, _IO_FILE *);
extern (C) int getchar_unlocked();
extern (C) uint rb_f_global_variables();
extern (C) uint rb_cv_get(uint, char *);
extern (C) uint rb_file_s_expand_path(int, uint *);
extern (C) uint rb_ary_plus(uint, uint);
extern (C) double rb_str_to_dbl(uint, int);
extern (C) int pthread_rwlock_rdlock(pthread_rwlock_t *);
extern (C) int getdate_r(char *, tm *);
extern (C) int clock_getres(int, timespec *);
extern (C) int rb_reg_options(uint);
extern (C) int sched_get_priority_max(int);
extern (C) void ruby_set_current_source();
extern (C) uint rb_str_inspect(uint);
extern (C) uint rb_ary_reverse(uint);
extern (C) int pthread_setschedprio(uint, int);
extern (C) int pthread_getcpuclockid(uint, int *);
extern (C) int pthread_barrierattr_getpshared(pthread_barrierattr_t *, int *);
extern (C) void * memmove(void *, void *, uint);
extern (C) uint rb_str_dup(uint);
extern (C) void rb_exc_raise(uint);
extern (C) uint gnu_dev_minor(ulong);
extern (C) uint rb_struct_define(char *, ...);
extern (C) int pthread_key_create(uint *, _BCD_func__1707);
extern (C) int sched_rr_get_interval(int, timespec *);
extern (C) int pthread_setcanceltype(int, int *);
extern (C) void rb_file_const(char *, uint);
extern (C) void * memcpy(void *, void *, uint);
extern (C) void rb_obj_call_init(uint, int, uint *);
extern (C) char * strncat(char *, char *, uint);
extern (C) int getitimer(int, itimerval *);
alias uint function(uint) _BCD_func__1880;
extern (C) uint rb_iterate(_BCD_func__1880, uint, _BCD_func__1839, uint);
extern (C) void * bsearch(void *, void *, uint, uint, _BCD_func__1775);
extern (C) uint rb_float_new(double);
extern (C) int vsprintf(char *, char *, char *);
extern (C) char * ctime_r(int *, char *);
extern (C) int vasprintf(char * *, char *, char *);
extern (C) uint rb_f_untrace_var(int, uint *);
extern (C) uint mbstowcs(wchar *, char *, uint);
extern (C) uint rb_const_get(uint, uint);
extern (C) uint rb_struct_getmember(uint, uint);
extern (C) int erand48_r(ushort *, drand48_data *, double *);
extern (C) uint rb_assoc_new(uint, uint);
extern (C) uint rb_gc_enable();
extern (C) int rb_is_local_id(uint);
extern (C) int pthread_condattr_init(pthread_condattr_t *);
extern (C) ulong rb_big2ull(uint);
extern (C) char * asctime(tm *);
alias uint function(uint, int) _BCD_func__1882;
extern (C) uint rb_values_at(uint, int, int, uint *, _BCD_func__1882);
extern (C) void rb_iter_break();
extern (C) int srandom_r(uint, random_data *);
extern (C) uint rb_apply(uint, uint, uint);
extern (C) int strcasecmp_l(char *, char *, __locale_struct *);
extern (C) uint rb_f_sprintf(int, uint *);
extern (C) uint rb_ary_delete_at(uint, int);
extern (C) uint rb_frame_last_func();
extern (C) int futimes(int, timeval *);
extern (C) uint rb_str_concat(uint, uint);
extern (C) uint rb_obj_remove_instance_variable(uint, uint);
extern (C) char * __stpcpy(char *, char *);
extern (C) void ruby_native_thread_kill(int);
extern (C) char * fcvt(double, int, int *, int *);
extern (C) char * qfcvt(real, int, int *, int *);
extern (C) uint rb_obj_is_instance_of(uint, uint);
extern (C) int mbtowc(wchar *, char *, uint);
extern (C) uint rb_define_class_under(uint, char *, uint);
alias void function(int) _BCD_func__1884;
extern (C) void ruby_posix_signal(int, _BCD_func__1884);
extern (C) int rb_is_const_id(uint);
extern (C) void rb_clear_cache_by_class(uint);
extern (C) int pthread_setconcurrency(int);
extern (C) int pthread_mutexattr_init(pthread_mutexattr_t *);
extern (C) void rb_frozen_class_p(uint);
extern (C) uint gnu_dev_major(ulong);
extern (C) void rb_str_update(uint, int, int, uint);
extern (C) uint rb_str_buf_cat(uint, char *, int);
extern (C) void rb_singleton_class_attached(uint, uint);
extern (C) int getpt();
extern (C) int futimesat(int, char *, timeval *);
extern (C) void abort();
extern (C) void ruby_load_script();
extern (C) int strncmp(char *, char *, uint);
extern (C) uint rb_const_get_at(uint, uint);
extern (C) void rb_interrupt();
extern (C) void lcong48(ushort *);
extern (C) _IO_FILE * fdopen(int, char *);
extern (C) int adjtime(timeval *, timeval *);
extern (C) _IO_FILE * freopen64(char *, char *, _IO_FILE *);
extern (C) void rb_thread_stop_timer();
extern (C) void rb_clear_cache();
extern (C) uint rb_detach_process(int);
extern (C) uint rb_big_or(uint, uint);
extern (C) char * strchrnul(char *, int);
extern (C) void rb_provide(char *);
extern (C) uint rb_hash_delete(uint, uint);
extern (C) uint rb_io_getc(uint);
extern (C) void ruby_stop(int);
extern (C) char * strncpy(char *, char *, uint);
extern (C) uint rb_str_substr(uint, int, int);
extern (C) uint rb_big_minus(uint, uint);
extern (C) int ruby_stack_length(uint * *);
extern (C) uint rb_proc_times(uint);
extern (C) void rb_define_alloc_func(uint, _BCD_func__1880);
extern (C) uint __ctype_get_mb_cur_max();
extern (C) char * strerror_l(int, __locale_struct *);
extern (C) int ftrylockfile(_IO_FILE *);
extern (C) int ruby_parser_stack_on_heap();
extern (C) int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
extern (C) uint rb_str_buf_new(int);
extern (C) int pthread_attr_getinheritsched(pthread_attr_t *, int *);
extern (C) void free(void *);
extern (C) int pthread_attr_getaffinity_np(pthread_attr_t *, uint, cpu_set_t *);
extern (C) int fileno_unlocked(_IO_FILE *);
extern (C) int sched_getaffinity(int, uint, cpu_set_t *);
extern (C) int initstate_r(uint, char *, uint, random_data *);
extern (C) int mblen(char *, uint);
extern (C) int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
extern (C) uint rb_str2inum(uint, int);
extern (C) void rb_lastline_set(uint);
extern (C) uint rb_time_new(int, int);
extern (C) int fgetpos(_IO_FILE *, _G_fpos64_t *);
extern (C) uint rb_method_dup(uint, uint, uint);
extern (C) char * rb_get_kcode();
extern (C) uint rb_cstr_to_inum(char *, int, int);
extern (C) void cfree(void *);
extern (C) char * strfry(char *);
extern (C) uint rb_ary_unshift(uint, uint);
extern (C) int timelocal(tm *);
extern (C) int pthread_rwlock_destroy(pthread_rwlock_t *);
extern (C) int snprintf(char *, uint, char *, ...);
extern (C) uint rb_ary_new2(int);
extern (C) uint rb_obj_instance_eval(int, uint *, uint);
extern (C) void ruby_incpush(char *);
extern (C) int rb_str_hash(uint);
extern (C) void * memccpy(void *, void *, int, uint);
extern (C) uint rb_num2ulong(uint);
extern (C) int clock_settime(int, timespec *);
extern (C) void * realloc(void *, uint);
extern (C) uint rb_big_clone(uint);
extern (C) int putchar_unlocked(int);
extern (C) void rb_gc_mark_parser();
extern (C) char * tmpnam(char *);
extern (C) char * cuserid(char *);
extern (C) void rb_hash_foreach(uint, _BCD_func__1836, uint);
extern (C) int ruby_exec();
extern (C) ulong strtoull(char *, char * *, int);
extern (C) void rb_gc_copy_finalizer(uint, uint);
extern (C) void rb_mark_end_proc();
extern (C) void rb_check_safe_str(uint);
extern (C) char * canonicalize_file_name(char *);
extern (C) uint rb_io_gets(uint);
extern (C) int rb_str_cmp(uint, uint);
extern (C) int pthread_cond_broadcast(pthread_cond_t *);
extern (C) uint rb_str_resize(uint, int);
extern (C) uint rb_gv_set(char *, uint);
extern (C) uint rb_io_ungetc(uint, uint);
extern (C) uint rb_define_class(char *, uint);
extern (C) char * tempnam(char *, char *);
extern (C) int pthread_getaffinity_np(uint, uint, cpu_set_t *);
extern (C) uint rb_singleton_class(uint);
extern (C) uint rb_module_new();
extern (C) uint rb_ary_concat(uint, uint);
extern (C) uint rb_eval_string_protect(char *, int *);
extern (C) void rb_backref_set(uint);
extern (C) void srand48(int);
extern (C) uint rb_ary_to_s(uint);
extern (C) int pthread_tryjoin_np(uint, void * *);
extern (C) uint rb_ary_new();
extern (C) uint rb_const_get_from(uint, uint);
extern (C) int pthread_spin_destroy(int *);
extern (C) char * strptime_l(char *, char *, tm *, __locale_struct *);
extern (C) uint rb_io_print(int, uint *, uint);
extern (C) int __overflow(_IO_FILE *, int);
extern (C) void rb_memerror();
extern (C) void rb_define_global_function(char *, _BCD_func__1839, int);
extern (C) int pthread_condattr_setclock(pthread_condattr_t *, int);
extern (C) uint * rb_svar(int);
extern (C) uint rb_check_string_type(uint);
extern (C) void rb_exec_end_proc();
extern (C) uint rb_sym_all_symbols();
extern (C) uint rb_class_init_copy(uint, uint);
extern (C) long rb_num2ll(uint);
extern (C) uint rb_fix2str(uint, int);
extern (C) void rb_cv_set(uint, char *, uint);
extern (C) void rb_define_readonly_variable(char *, uint *);
extern (C) uint rb_funcall_rescue(uint, uint, int, ...);
extern (C) void rb_kcode_reset_option();
extern (C) int putenv(char *);
extern (C) int timer_delete(void *);
extern (C) void rb_define_protected_method(uint, char *, _BCD_func__1839, int);
extern (C) void rb_const_set(uint, uint, uint);
extern (C) uint rb_ary_cmp(uint, uint);
extern (C) int pthread_spin_unlock(int *);
extern (C) void rb_str_associate(uint, uint);
extern (C) int settimeofday(timeval *, timezone *);
extern (C) int rb_thread_alone();
extern (C) int fscanf(_IO_FILE *, char *, ...);
extern (C) int ecvt_r(double, int, int *, int *, char *, uint);
extern (C) int qecvt_r(real, int, int *, int *, char *, uint);
extern (C) void rb_mem_clear(uint *, int);
extern (C) int rb_respond_to(uint, uint);
extern (C) uint rb_any_to_s(uint);
extern (C) uint rb_dvar_ref(uint);
extern (C) int ffsll(long);
extern (C) void rb_glob(char *, _BCD_func__1845, uint);
extern (C) void perror(char *);
extern (C) char * strerror_r(int, char *, uint);
extern (C) div_t div(int, int);
extern (C) uint rb_class_new(uint);
extern (C) uint rb_big2str0(uint, int, int);
extern (C) int rb_is_class_id(uint);
extern (C) uint rb_thread_main();
extern (C) uint rb_inspecting_p(uint);
extern (C) int pthread_attr_setguardsize(pthread_attr_t *, uint);
extern (C) int rb_symname_p(char *);
extern (C) int rb_method_boundp(uint, uint, int);
extern (C) uint rb_struct_s_members(uint);
extern (C) uint rb_ary_aref(int, uint *, uint);
extern (C) int mrand48();
extern (C) int rb_special_const_p(uint);
extern (C) int obstack_printf(void *, char *, ...);
extern (C) void * ruby_xcalloc(int, int);
extern (C) void * alloca(uint);
extern (C) uint rb_check_array_type(uint);
extern (C) int getloadavg(double *, int);
extern (C) uint rb_f_exit(int, uint *);
extern (C) int pthread_detach(uint);
extern (C) char * strcat(char *, char *);
extern (C) void rb_gc_mark(uint);
extern (C) char * stpncpy(char *, char *, uint);
extern (C) int pthread_equal(uint, uint);
extern (C) int fileno(_IO_FILE *);
extern (C) void rb_check_type(uint, int);
extern (C) int ferror(_IO_FILE *);
extern (C) uint rb_struct_alloc(uint, uint);
extern (C) int pthread_condattr_destroy(pthread_condattr_t *);
extern (C) uint rb_hash_aset(uint, uint, uint);
extern (C) void rb_gc_mark_maybe(uint);
extern (C) int rb_block_given_p();
extern (C) void ruby_process_options(int, char * *);
extern (C) int vfscanf(_IO_FILE *, char *, char *);
extern (C) void rb_mark_generic_ivar_tbl();
extern (C) int lrand48_r(drand48_data *, int *);
extern (C) void qsort_r(void *, uint, uint, _BCD_func__1691, void *);
extern (C) void __sched_cpufree(cpu_set_t *);
extern (C) uint rb_str_dump(uint);
extern (C) void rb_undef_alloc_func(uint);
extern (C) void setkey(char *);
extern (C) int pselect(int, fd_set *, fd_set *, fd_set *, timespec *, __sigset_t *);
extern (C) void rb_gc_mark_locations(uint *, uint *);
extern (C) uint rb_autoload_load(uint, uint);
extern (C) int clock_gettime(int, timespec *);
extern (C) char * strptime(char *, char *, tm *);
extern (C) int scanf(char *, ...);
extern (C) char * strchr(char *, int);
extern (C) int pthread_attr_getstack(pthread_attr_t *, void * *, uint *);
extern (C) char * rb_path_skip_prefix(char *);
extern (C) uint rb_str_times(uint, uint);
extern (C) void rb_ary_store(uint, int, uint);
extern (C) uint rb_reg_nth_defined(int, uint);
extern (C) void rb_thread_schedule();
extern (C) tm * localtime(int *);
extern (C) void __bzero(void *, uint);
extern (C) void pthread_testcancel();
extern (C) int pthread_timedjoin_np(uint, void * *, timespec *);
extern (C) uint strftime_l(char *, uint, char *, tm *, __locale_struct *);
extern (C) uint rb_num_coerce_cmp(uint, uint);
extern (C) int fsetpos(_IO_FILE *, _G_fpos64_t *);
extern (C) uint rb_Float(uint);
extern (C) int _IO_putc(int, _IO_FILE *);
extern (C) void rb_thread_atfork();
extern (C) uint rb_ivar_get(uint, uint);
extern (C) int rb_eql(uint, uint);
extern (C) uint rb_const_list(void *);
extern (C) int strcmp(char *, char *);
extern (C) double rb_big2dbl(uint);
extern (C) uint rb_io_close(uint);
extern (C) void rb_kcode_set_option(uint);
extern (C) void rb_gc_call_finalizer_at_exit();
extern (C) uint rb_obj_method(uint, uint);
extern (C) int seed48_r(ushort *, drand48_data *);
extern (C) uint rb_str_split(uint, char *);
extern (C) int pthread_key_delete(uint);
extern (C) uint rb_file_expand_path(uint, uint);
extern (C) uint rb_str_new2(char *);
extern (C) void * valloc(uint);
extern (C) int drand48_r(drand48_data *, double *);
extern (C) char * strcpy(char *, char *);
extern (C) int _IO_vfprintf(_IO_FILE *, char *, char *);
extern (C) int fcvt_r(double, int, int *, int *, char *, uint);
extern (C) int qfcvt_r(real, int, int *, int *, char *, uint);
extern (C) void tzset();
extern (C) uint rb_str_new5(uint, char *, int);
extern (C) char * strcasestr(char *, char *);
extern (C) uint rb_protect_inspect(_BCD_func__1839, uint, uint);
extern (C) uint rb_big_rshift(uint, uint);
extern (C) void rb_str_set_len(uint, int);
extern (C) int _IO_feof(_IO_FILE *);
extern (C) int rename(char *, char *);
extern (C) void rb_include_module(uint, uint);
extern (C) void rb_global_variable(uint *);
extern (C) uint rb_Array(uint);
extern (C) double erand48(ushort *);
extern (C) uint rb_protect(_BCD_func__1880, uint, int *);
extern (C) void rb_define_variable(char *, uint *);
extern (C) int getdelim(char * *, uint *, int, _IO_FILE *);
extern (C) uint rb_f_exec(int, uint *);
extern (C) long _IO_seekoff(_IO_FILE *, long, int, int);
extern (C) char * basename(char *);
extern (C) uint rb_ary_assoc(uint, uint);
extern (C) uint rb_gets();
extern (C) void * memfrob(void *, uint);
extern (C) int pthread_barrier_destroy(pthread_barrier_t *);
extern (C) int pthread_rwlock_init(pthread_rwlock_t *, pthread_rwlockattr_t *);
extern (C) void ruby_init_loadpath();
extern (C) void rb_define_method_id(uint, uint, _BCD_func__1839, int);
extern (C) int clock_getcpuclockid(int, int *);
extern (C) uint rb_class_real(uint);
extern (C) uint rb_exc_new(uint, char *, int);
extern (C) int pthread_setspecific(uint, void *);
extern (C) int random_r(random_data *, int *);
extern (C) void rb_load_fail(char *);
extern (C) char * initstate(uint, char *, uint);
extern (C) int rb_find_file_ext(uint *, char * *);
extern (C) int fsetpos64(_IO_FILE *, _G_fpos64_t *);
extern (C) int rb_big2long(uint);
extern (C) int pthread_attr_setinheritsched(pthread_attr_t *, int);
extern (C) ulong strtoull_l(char *, char * *, int, __locale_struct *);
extern (C) int pthread_attr_getguardsize(pthread_attr_t *, uint *);
extern (C) uint _IO_sgetn(_IO_FILE *, void *, uint);
extern (C) void clearerr_unlocked(_IO_FILE *);
extern (C) uint rb_class_private_instance_methods(int, uint *, uint);
extern (C) void rb_write_error(char *);
extern (C) void rb_set_class_path(uint, uint, char *);
extern (C) uint rb_big_rand(uint, double *);
extern (C) int getsubopt(char * *, char * *, char * *);
extern (C) char * ctermid(char *);
extern (C) uint rb_reg_new(char *, int, int);
extern (C) int fputc_unlocked(int, _IO_FILE *);
extern (C) void ruby_xfree(void *);
extern (C) int pthread_mutex_destroy(pthread_mutex_t *);
extern (C) uint rb_ensure(_BCD_func__1839, uint, _BCD_func__1839, uint);
extern (C) char * strtok(char *, char *);
extern (C) int pthread_attr_getschedpolicy(pthread_attr_t *, int *);
extern (C) uint rb_str_cat2(uint, char *);
extern (C) uint rb_str_to_str(uint);
extern (C) uint rb_thread_current();
extern (C) void rb_attr(uint, uint, int, int, int);
extern (C) char * strtok_r(char *, char *, char * *);
extern (C) _IO_FILE * freopen(char *, char *, _IO_FILE *);
extern (C) int ruby_cleanup(int);
extern (C) char * __stpncpy(char *, char *, uint);
extern (C) int fputc(int, _IO_FILE *);
extern (C) int fputs(char *, _IO_FILE *);
extern (C) int pthread_barrier_wait(pthread_barrier_t *);
extern (C) void rb_throw(char *, uint);
extern (C) void ruby_set_argv(int, char * *);
extern (C) int rand_r(uint *);
extern (C) void * memset(void *, int, uint);
extern (C) uint rb_mod_included_modules(uint);
extern (C) int pthread_attr_setstacksize(pthread_attr_t *, uint);
extern (C) int _IO_ferror(_IO_FILE *);
extern (C) int getc_unlocked(_IO_FILE *);
extern (C) int strncasecmp_l(char *, char *, uint, __locale_struct *);
extern (C) int ftell(_IO_FILE *);
extern (C) uint rb_f_kill(int, uint *);
extern (C) uint rb_convert_type(uint, int, char *, char *);
extern (C) int sched_getcpu();
extern (C) uint rb_cvar_get(uint, uint);
extern (C) uint rb_ary_new3(int, ...);
extern (C) uint rb_ary_new4(int, uint *);
extern (C) void rb_fatal(char *, ...);
extern (C) uint rb_call_super(int, uint *);
extern (C) uint rb_class_instance_methods(int, uint *, uint);
extern (C) uint rb_obj_instance_variables(uint);
extern (C) char * strndup(char *, uint);
extern (C) int pthread_mutexattr_getrobust_np(pthread_mutexattr_t *, int *);
extern (C) void * ruby_xmalloc(int);
extern (C) void setbuffer(_IO_FILE *, char *, uint);
extern (C) int ruby_brace_glob(char *, int, _BCD_func__1144, uint);
extern (C) uint rb_eval_cmd(uint, uint, int);
extern (C) uint rb_str_new3(uint);
extern (C) uint rb_str_new4(uint);
extern (C) int pthread_attr_destroy(pthread_attr_t *);
extern (C) uint rb_class_boot(uint);
extern (C) void rb_mark_hash(void *);
extern (C) uint rb_to_int(uint);
extern (C) void rb_undef_method(uint, char *);
extern (C) int pthread_barrierattr_destroy(pthread_barrierattr_t *);
extern (C) int sched_setscheduler(int, int, sched_param *);
extern (C) uint rb_int2big(int);
extern (C) int is_ruby_native_thread();
extern (C) real strtold(char *, char * *);
extern (C) uint rb_mod_class_variables(uint);
extern (C) uint rb_class_of(uint);
extern (C) uint rb_quad_unpack(char *, int);
extern (C) uint rb_reg_last_match(uint);
extern (C) void rb_set_kcode(char *);
extern (C) void rb_gc();
extern (C) uint rb_range_new(uint, uint, int);
extern (C) void exit(int);
extern (C) char * setstate(char *);
extern (C) void _IO_funlockfile(_IO_FILE *);
extern (C) uint rb_uint2big(uint);
extern (C) int pclose(_IO_FILE *);
extern (C) int __getdelim(char * *, uint *, int, _IO_FILE *);
extern (C) uint rb_str_tmp_new(int);
extern (C) void srandom(uint);
extern (C) uint rb_big_plus(uint, uint);
extern (C) uint rb_reg_match_pre(uint);
extern (C) uint rb_obj_tainted(uint);
extern (C) void rb_obj_infect(uint, uint);

//extern (C) int rb_type(uint);

int rb_type(VALUE obj)
{
    //if (FIXNUM_P(obj)) return T_FIXNUM;
    if (obj == Qnil) return T_NIL;
    if (obj == Qfalse) return T_FALSE;
    if (obj == Qtrue) return T_TRUE;
    if (obj == Qundef) return T_UNDEF;
    //if (SYMBOL_P(obj)) return T_SYMBOL;
    return BUILTIN_TYPE(obj);
}

alias rb_type TYPE;

int BUILTIN_TYPE(VALUE x)
{
  return RBASIC(x).flags & T_MASK;
}

extern (C) char * tmpnam_r(char *);
extern (C) char * gcvt(double, int, char *);
extern (C) char * qgcvt(real, int, char *);
extern (C) int pthread_spin_lock(int *);
extern (C) uint rb_marshal_load(uint);
extern (C) void rb_exc_fatal(uint);
extern (C) long strtoq(char *, char * *, int);
extern (C) int rb_obj_respond_to(uint, uint, int);
extern (C) void rb_define_alias(uint, char *, char *);
extern (C) void * malloc(uint);
extern (C) ldiv_t ldiv(int, int);
extern (C) int random();
extern (C) void rb_secure_update(uint);
extern (C) uint rb_each(uint);
extern (C) int _IO_peekc_locked(_IO_FILE *);
extern (C) int strcoll(char *, char *);
extern (C) int strncasecmp(char *, char *, uint);
extern (C) void rb_error_frozen(char *);
extern (C) uint rb_thread_create(_BCD_func__1839, void *);
extern (C) double strtod_l(char *, char * *, __locale_struct *);
extern (C) void rb_gc_finalize_deferred();
extern (C) uint rb_reg_match_last(uint);
extern (C) int fclose(_IO_FILE *);
extern (C) int pthread_mutex_consistent_np(pthread_mutex_t *);
extern (C) int clock();
extern (C) uint rb_equal(uint, uint);
extern (C) int rb_proc_exec(char *);

VALUE INT2FIX(long i)
{
  return (cast(VALUE)((cast(uint)i)<<1 | FIXNUM_FLAG));
}
alias INT2FIX LONG2FIX;
alias INT2FIX rb_fix_new;

extern (C) uint rb_int2inum(int);
alias rb_int2inum INT2NUM;
alias INT2NUM LONG2NUM;
alias rb_int2inum rb_int_new;

extern (C) uint rb_uint2inum(uint);
alias rb_uint2inum UINT2NUM;
alias UINT2NUM ULONG2NUM;
alias rb_uint2inum rb_uint_new;

extern (C) uint rb_ll2inum(long);
alias rb_ll2inum LL2NUM; 
extern (C) uint rb_ull2inum(ulong);
alias rb_ull2inum ULL2NUM;

//if(SIZEOF_OFF_T > SIZEOF_LONG && HAVE_LONG_LONG)
  alias LL2NUM OFFT2NUM;
//else
//  alias INT2NUM OFFT2NUM;


extern (C) long strtoll_l(char *, char * *, int, __locale_struct *);
extern (C) int pthread_rwlock_trywrlock(pthread_rwlock_t *);
extern (C) uint rb_reg_match(uint, uint);
extern (C) uint rb_obj_is_kind_of(uint, uint);
extern (C) int pthread_cond_signal(pthread_cond_t *);
extern (C) int rb_const_defined(uint, uint);
extern (C) int ruby_brace_expand(char *, int, _BCD_func__1144, uint);
extern (C) void rb_mark_generic_ivar(uint);
extern (C) int unsetenv(char *);
extern (C) double rb_genrand_real();
extern (C) void rb_define_global_const(char *, uint);
extern (C) char * __strtok_r(char *, char *, char * *);
alias void function(int, void *) _BCD_func__1921;
extern (C) int on_exit(_BCD_func__1921, void *);
extern (C) uint rb_proc_call(uint, uint);
extern (C) void * calloc(uint, uint);
extern (C) int sscanf(char *, char *, ...);
extern (C) int srand48_r(int, drand48_data *);
extern (C) uint rb_eval_string(char *);
extern (C) int mkostemp64(char *, int);
extern (C) void rb_jump_tag(int);
extern (C) uint rb_num2fix(uint);
extern (C) uint rb_ary_push(uint, uint);
extern (C) uint rb_iv_get(uint, char *);
extern (C) int rb_thread_select(int, fd_set *, fd_set *, fd_set *, timeval *);
extern (C) uint rb_big2ulong(uint);
extern (C) void ruby_show_copyright();
extern (C) void ruby_script(char *);
extern (C) int pthread_rwlock_wrlock(pthread_rwlock_t *);
extern (C) void _IO_free_backup_area(_IO_FILE *);
extern (C) uint rb_block_proc();
extern (C) uint fwrite(void *, uint, uint, _IO_FILE *);
extern (C) void rb_bug(char *, ...);
extern (C) uint rb_ivar_defined(uint, uint);
extern (C) int pthread_cond_init(pthread_cond_t *, pthread_condattr_t *);
extern (C) long atoll(char *);
extern (C) int ungetc(int, _IO_FILE *);
extern (C) int pthread_attr_setstackaddr(pthread_attr_t *, void *);
extern (C) uint rb_backref_get();
extern (C) int pthread_attr_getstacksize(pthread_attr_t *, uint *);
extern (C) uint rb_id_attrset(uint);
extern (C) int clone(_BCD_func__256, void *, int, void *, ...);
extern (C) uint rb_str_to_inum(uint, int, int);
extern (C) int posix_memalign(void * *, uint, uint);
extern (C) char * getenv(char *);
extern (C) char * strrchr(char *, int);
extern (C) uint rb_str_append(uint, uint);
extern (C) int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
extern (C) int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
extern (C) uint rb_define_module_id(uint);
extern (C) uint rb_thread_local_aref(uint, uint);
extern (C) uint strxfrm(char *, char *, uint);
extern (C) uint rb_struct_aset(uint, uint, uint);
extern (C) int clock_nanosleep(int, int, timespec *, timespec *);
extern (C) uint rb_ary_dup(uint);
extern (C) uint rb_f_lambda();
extern (C) void rb_notimplement();
extern (C) uint rb_singleton_class_clone(uint);
extern (C) tm * localtime_r(int *, tm *);
extern (C) void rb_str_modify(uint);
extern (C) void rb_gc_unregister_address(uint *);
extern (C) uint rb_String(uint);
extern (C) int sched_getscheduler(int);
extern (C) int pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t *);
extern (C) long strtoll(char *, char * *, int);
extern (C) uint rb_exc_new2(uint, char *);
extern (C) uint rb_exc_new3(uint, uint);
extern (C) char * strerror(int);
extern (C) void rb_big_2comp(uint);
extern (C) uint rb_mod_remove_const(uint, uint);
extern (C) tm * getdate(char *);
extern (C) uint strnlen(char *, uint);
extern (C) uint rb_obj_as_string(uint);
extern (C) int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
extern (C) void ruby_finalize();
extern (C) void rb_alias_variable(uint, uint);
extern (C) void rb_thread_sleep(int);
extern (C) int mkostemp(char *, int);
extern (C) void ruby_default_signal(int);
extern (C) int dysize(int);
extern (C) uint rb_ary_includes(uint, uint);
extern (C) uint rb_str_buf_cat2(uint, char *);
extern (C) int stime(int *);
extern (C) uint rb_ary_entry(uint, int);
extern (C) int pthread_cancel(uint);
extern (C) int lutimes(char *, timeval *);
extern (C) uint rb_struct_new(uint, ...);
extern (C) int system(char *);
extern (C) char * rb_class2name(uint);
extern (C) uint rb_thread_alive_p(uint);
extern (C) uint rb_find_file(uint);
extern (C) _IO_FILE * fopencookie(void *, char *, _IO_cookie_io_functions_t);
extern (C) int __sched_cpucount(uint, cpu_set_t *);
extern (C) uint rb_cstr2inum(char *, int);
extern (C) uint rb_cvar_defined(uint, uint);
extern (C) void * ruby_xrealloc(void *, int);
extern (C) int getline(char * *, uint *, _IO_FILE *);
alias void function(uint) _BCD_func__1923;
extern (C) void rb_set_end_proc(_BCD_func__1923, uint);
extern (C) void rb_dvar_push(uint, uint);
extern (C) int pthread_rwlockattr_init(pthread_rwlockattr_t *);
extern (C) uint rb_str_unlocktmp(uint);
extern (C) void rb_str_setter(uint, uint, uint *);
extern (C) ulong gnu_dev_makedev(uint, uint);
extern (C) char * strpbrk(char *, char *);
extern (C) uint rb_check_array_value(uint);
extern (C) int rpmatch(char *);
extern (C) uint strtoul(char *, char * *, int);
extern (C) uint rb_io_eof(uint);
extern (C) ulong strtouq(char *, char * *, int);
extern (C) void rb_check_safe_obj(uint);
extern (C) int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *, int *);
extern (C) int timer_create(int, void *, void * *);
extern (C) uint rb_ivar_set(uint, uint, uint);
extern (C) uint strcspn(char *, char *);
extern (C) uint rb_class_inherited_p(uint, uint);
extern (C) void * rb_mod_const_at(uint, void *);
extern (C) int rb_const_defined_from(uint, uint);
extern (C) uint rb_check_to_integer(uint, char *);
extern (C) char * ruby_signal_name(int);
extern (C) char * strsignal(int);
extern (C) int putc(int, _IO_FILE *);
extern (C) int pthread_setschedparam(uint, int, sched_param *);
extern (C) int pthread_condattr_getpshared(pthread_condattr_t *, int *);
extern (C) void rb_undef(uint, uint);
extern (C) int puts(char *);
extern (C) int putw(int, _IO_FILE *);
extern (C) uint rb_str_buf_new2(char *);
extern (C) int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
extern (C) uint rb_ary_shift(uint);
extern (C) void rb_raise(uint, char *, ...);
extern (C) uint rb_check_convert_type(uint, int, char *, char *);
extern (C) uint rb_io_printf(int, uint *, uint);
extern (C) int rb_scan_args(int, uint *, char *, ...);
extern (C) void _IO_cookie_init(void *, int, void *, _IO_cookie_io_functions_t);
extern (C) int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
extern (C) uint rb_obj_clone(uint);
extern (C) int pthread_rwlock_unlock(pthread_rwlock_t *);
extern (C) int nanosleep(timespec *, timespec *);
extern (C) uint rb_obj_freeze(uint);
extern (C) uint rb_hash(uint);
extern (C) uint rb_hash_new();
extern (C) int pthread_attr_setstack(pthread_attr_t *, void *, uint);
extern (C) uint rb_class_path(uint);
extern (C) _IO_FILE * fopen(char *, char *);
extern (C) int labs(int);
extern (C) int pthread_mutex_trylock(pthread_mutex_t *);
extern (C) int pthread_attr_setschedpolicy(pthread_attr_t *, int);
extern (C) int __sigsetjmp(void *, int);
extern (C) uint rb_class_inherited(uint, uint);
extern (C) int fprintf(_IO_FILE *, char *, ...);
extern (C) uint rb_big_and(uint, uint);
extern (C) int ptsname_r(int, char *, uint);
extern (C) char * stpcpy(char *, char *);
extern (C) int rb_is_junk_id(uint);
extern (C) ulong rb_num2ull(uint);
extern (C) void rb_dvar_asgn(uint, uint);
extern (C) void rb_define_private_method(uint, char *, _BCD_func__1839, int);
extern (C) uint rb_thread_stop();
extern (C) void rb_thread_polling();
extern (C) int pthread_rwlockattr_getkind_np(pthread_rwlockattr_t *, int *);
extern (C) int sched_get_priority_min(int);
extern (C) char * strdup(char *);
extern (C) int pthread_attr_getschedparam(pthread_attr_t *, sched_param *);
extern (C) int memcmp(void *, void *, uint);
extern (C) int pthread_attr_getstackaddr(pthread_attr_t *, void * *);
extern (C) int timer_settime(void *, int, itimerspec *, itimerspec *);
extern (C) int bcmp(void *, void *, uint);
extern (C) uint rb_newobj();
extern (C) uint rb_str_plus(uint, uint);
extern (C) uint rb_str_locktmp(uint);
extern (C) void rb_check_inheritable(uint);
extern (C) int dprintf(int, char *, ...);
extern (C) int timer_getoverrun(void *);
extern (C) int atol(char *);
extern (C) uint rb_file_directory_p(uint, uint);
extern (C) char * l64a(int);
extern (C) int mkstemp64(char *);
extern (C) void * rawmemchr(void *, int);
extern (C) int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
extern (C) uint rb_attr_get(uint, uint);
extern (C) char * rb_path_next(char *);
extern (C) int rb_env_path_tainted();
extern (C) uint rb_catch(char *, _BCD_func__1839, uint);
extern (C) int pthread_barrierattr_init(pthread_barrierattr_t *);
extern (C) void rb_copy_generic_ivar(uint, uint);
extern (C) uint strxfrm_l(char *, char *, uint, __locale_struct *);
extern (C) uint rb_funcall(uint, uint, int, ...);
extern (C) void rb_parser_append_print();
extern (C) int ruby_glob(char *, int, _BCD_func__1144, uint);
extern (C) uint fread(void *, uint, uint, _IO_FILE *);
extern (C) void ruby_run();
extern (C) int pthread_attr_setdetachstate(pthread_attr_t *, int);
extern (C) int unlockpt(int);
extern (C) void srand(uint);
extern (C) uint rb_Integer(uint);
extern (C) uint rb_class_new_instance(int, uint *, uint);
extern (C) int pthread_barrier_init(pthread_barrier_t *, pthread_barrierattr_t *, uint);
extern (C) void rb_write_error2(char *, int);
extern (C) long _IO_seekpos(_IO_FILE *, long, int);
extern (C) char * rb_path_last_separator(char *);
extern (C) char * mktemp(char *);
extern (C) int strtol_l(char *, char * *, int, __locale_struct *);
extern (C) void ruby_options(int, char * *);
extern (C) char * fgets_unlocked(char *, int, _IO_FILE *);
extern (C) int lcong48_r(ushort *, drand48_data *);
extern (C) uint rb_to_id(uint);
extern (C) uint rb_thread_wakeup_alive(uint);
extern (C) void ruby_init_stack(uint *);
extern (C) void rb_free_generic_ivar(uint);
extern (C) char * strsep(char * *, char *);
alias void function() _BCD_func__1937;
extern (C) int atexit(_BCD_func__1937);
extern (C) uint rb_ary_join(uint, uint);
extern (C) uint rb_obj_singleton_methods(int, uint *, uint);
extern (C) void rb_gc_mark_global_tbl();
extern (C) void rb_invalid_str(char *, char *);
extern (C) uint rb_autoload_p(uint, uint);
extern (C) int ferror_unlocked(_IO_FILE *);
extern (C) uint rb_block_dup(uint, uint, uint);
extern (C) uint rb_iv_set(uint, char *, uint);
extern (C) void rb_sys_warning(char *, ...);
extern (C) uint rb_str_buf_append(uint, uint);
extern (C) uint rb_io_binmode(uint);
extern (C) int __uflow(_IO_FILE *);
extern (C) int fputs_unlocked(char *, _IO_FILE *);
extern (C) uint pthread_self();
extern (C) void rb_secure(int);
extern (C) int setenv(char *, char *, int);
extern (C) cpu_set_t * __sched_cpualloc(uint);
extern (C) void pthread_exit(void *);
extern (C) int strverscmp(char *, char *);
extern (C) void rb_thread_fd_close(int);
extern (C) int pthread_spin_init(int *, int);
extern (C) uint strtoul_l(char *, char * *, int, __locale_struct *);
extern (C) void rb_alias(uint, uint, uint);
extern (C) uint rb_f_trace_var(int, uint *);
extern (C) int gettimeofday(timeval *, timezone *);
extern (C) int rb_path_check(char *);
extern (C) int sched_getparam(int, sched_param *);
extern (C) void rb_quad_pack(char *, uint);
extern (C) uint rb_str_cat(uint, char *, int);
extern (C) void * pthread_getspecific(uint);
extern (C) int vfprintf(_IO_FILE *, char *, char *);
extern (C) int pthread_setcancelstate(int, int *);
extern (C) void rb_cvar_set(uint, uint, uint, int);
extern (C) int pthread_once(int *, _BCD_func__1937);
extern (C) void rb_exit(int);
extern (C) int time(int *);
extern (C) int pthread_getattr_np(uint, pthread_attr_t *);
extern (C) uint rb_ary_freeze(uint);
extern (C) int ruby_yyparse();
extern (C) uint rb_io_write(uint, uint);
extern (C) uint rb_hash_lookup(uint, uint);
extern (C) uint strftime(char *, uint, char *, tm *);
extern (C) int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
extern (C) void rb_thread_wait_for(timeval);
extern (C) int a64l(char *);
extern (C) void * __mempcpy(void *, void *, uint);
extern (C) void rb_syswait(int);
extern (C) int sched_setparam(int, sched_param *);
extern (C) uint strspn(char *, char *);
extern (C) char * __secure_getenv(char *);
extern (C) int _IO_getc(_IO_FILE *);
extern (C) uint rb_mod_init_copy(uint, uint);
alias uint function(uint, uint, int) _BCD_func__1940;
extern (C) uint rb_exec_recursive(_BCD_func__1940, uint, uint);
//extern (C) void rb_define_method(uint, char *, _BCD_func__1839, int);
extern (C) void rb_define_method(VALUE, char*,VALUE function(),int);
extern (C) int vdprintf(int, char *, char *);
extern (C) _IO_FILE * open_memstream(char * *, uint *);
extern (C) int rb_memcmp(void *, void *, int);
extern (C) void rb_autoload(uint, uint, char *);
extern (C) void * rb_generic_ivar_table(uint);
extern (C) int pthread_mutex_unlock(pthread_mutex_t *);
extern (C) uint rb_genrand_int32();
extern (C) char * ctime(int *);
extern (C) uint rb_mod_const_missing(uint, uint);
extern (C) uint rb_struct_iv_get(uint, char *);
extern (C) uint rb_rescue2(_BCD_func__1839, uint, _BCD_func__1839, uint, ...);
extern (C) uint rb_big_pow(uint, uint);
extern (C) char * strstr(char *, char *);
extern (C) uint rb_dbl2big(double);
extern (C) void rb_remove_method(uint, char *);
extern (C) uint rb_reg_match_post(uint);
extern (C) uint rb_require_safe(uint, int);
extern (C) void rb_compile_error_append(char *, ...);
extern (C) char * ecvt(double, int, int *, int *);
extern (C) uint rb_thread_kill(uint);
extern (C) uint rb_reg_nth_match(int, uint);
extern (C) int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, timespec *);
extern (C) int pthread_rwlock_timedwrlock(pthread_rwlock_t *, timespec *);
extern (C) char * index(char *, int);
extern (C) char * rb_obj_classname(uint);
extern (C) uint rb_intern(char *);
extern (C) int timer_gettime(void *, itimerspec *);
extern (C) uint strlen(char *);
extern (C) int nrand48(ushort *);
extern (C) void rewind(_IO_FILE *);
extern (C) uint rb_io_addstr(uint, uint);
extern (C) int mktime(tm *);
extern (C) void rb_gc_register_address(uint *);
extern (C) int fflush_unlocked(_IO_FILE *);
extern (C) uint rb_big_lshift(uint, uint);
extern (C) void * memmem(void *, uint, void *, uint);
extern (C) uint fread_unlocked(void *, uint, uint, _IO_FILE *);
extern (C) void rb_check_frozen(uint);
extern (C) uint rb_enumeratorize(uint, uint, int, uint *);
extern (C) uint rb_define_class_id(uint, uint);
extern (C) uint rb_frame_this_func();
extern (C) int unshare(int);
extern (C) double rb_cstr_to_dbl(char *, int);
extern (C) int _IO_padn(_IO_FILE *, int, int);
extern (C) void flockfile(_IO_FILE *);
extern (C) int lrand48();
extern (C) int pthread_setaffinity_np(uint, uint, cpu_set_t *);
extern (C) int nrand48_r(ushort *, drand48_data *, int *);
extern (C) uint rb_inspect(uint);
extern (C) uint rb_obj_untaint(uint);
extern (C) int pthread_attr_getdetachstate(pthread_attr_t *, int *);
extern (C) int pthread_yield();
extern (C) int pthread_atfork(_BCD_func__1937, _BCD_func__1937, _BCD_func__1937);
extern (C) int ffs(int);
extern (C) int select(int, fd_set *, fd_set *, fd_set *, timeval *);
extern (C) int vscanf(char *, char *);
extern (C) uint rb_big2str(uint, int);
extern (C) uint rb_file_open(char *, char *);
extern (C) uint rb_obj_class(uint);
extern (C) uint rb_io_puts(int, uint *, uint);
extern (C) void rb_define_class_variable(uint, char *, uint);
extern (C) void ruby_show_version();
extern (C) long rb_big2ll(uint);
extern (C) char * rb_id2name(uint);
extern (C) uint rb_mod_name(uint);
extern (C) void rb_load(uint, int);
extern (C) int feof(_IO_FILE *);
extern (C) void rb_gc_mark_trap_list();
extern (C) uint rb_ary_pop(uint);
extern (C) char * asctime_r(tm *, char *);
extern (C) int pthread_attr_setaffinity_np(pthread_attr_t *, uint, cpu_set_t *);
extern (C) tm * gmtime_r(int *, tm *);
extern (C) int jrand48_r(ushort *, drand48_data *, int *);
extern (C) int fgetc(_IO_FILE *);
extern (C) uint rb_class_protected_instance_methods(int, uint *, uint);
extern (C) char * fgets(char *, int, _IO_FILE *);
extern (C) uint rb_str_dup_frozen(uint);
extern (C) uint rb_yield_splat(uint);
extern (C) int rb_thread_fd_writable(int);
extern (C) int rand();
extern (C) int sched_setaffinity(int, uint, cpu_set_t *);
extern (C) uint rb_thread_local_aset(uint, uint, uint);
extern (C) uint rb_big_norm(uint);
extern (C) void * memrchr(void *, int, uint);
extern (C) uint rb_f_require(uint, uint);
extern (C) uint rb_range_beg_len(uint, int *, int *, int, int);
extern (C) void rb_cmperr(uint, uint);
extern (C) uint rb_ary_clear(uint);
extern (C) char * rb_path_end(char *);
extern (C) ushort * seed48(ushort *);
extern (C) int pthread_getconcurrency();
extern (C) void rb_set_safe_level(int);
extern (C) int rb_memsearch(void *, int, void *, int);
extern (C) void * mempcpy(void *, void *, uint);
extern (C) uint rb_yield(uint);
extern (C) void rb_name_error(uint, char *, ...);
extern (C) int rb_during_gc();
extern (C) uint rb_define_module(char *);
extern (C) uint rb_struct_aref(uint, uint);
extern (C) lldiv_t lldiv(long, long);
extern (C) uint rb_tainted_str_new(char *, int);
extern (C) uint rb_gc_disable();
extern (C) void rb_define_const(uint, char *, uint);
extern (C) int rb_sym_interned_p(uint);
extern (C) int _IO_vfscanf(_IO_FILE *, char *, char *, int *);
extern (C) int pthread_rwlock_timedrdlock(pthread_rwlock_t *, timespec *);
extern (C) uint rb_dbl_cmp(double, double);
extern (C) void rb_load_protect(uint, int, int *);
extern (C) int _IO_ftrylockfile(_IO_FILE *);
extern (C) int strcoll_l(char *, char *, __locale_struct *);
extern (C) uint rb_class_public_instance_methods(int, uint *, uint);
extern (C) int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *);
extern (C) void ruby_prog_init();
extern (C) int abs(int);
extern (C) uint rb_struct_members(uint);
extern (C) int pthread_attr_getscope(pthread_attr_t *, int *);
extern (C) int utimes(char *, timeval *);
struct itimerspec {
timespec it_interval;
timespec it_value;
}
struct timeval {
int tv_sec;
int tv_usec;
}
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
int tm_gmtoff;
char * tm_zone;
}
struct __pthread_internal_slist {
__pthread_internal_slist * __next;
}
union N6RArray4__26E {
int capa;
uint shared2;
}
struct RArray {
RBasic basic;
int len;
N6RArray4__26E aux;
uint * ptr;
}
struct RStruct {
RBasic basic;
int len;
uint * ptr;
}
struct RFloat {
RBasic basic;
double value;
}
union N7RString4__25E {
int capa;
uint shared2;
}
struct RString {
  RBasic basic;
  int len;
  char * ptr;
  N7RString4__25E aux;
}
struct div_t {
int quot;
int rem;
}
union N15pthread_mutex_t17__pthread_mutex_s4__10E {
int __spins;
__pthread_internal_slist __list;
}
struct __pthread_mutex_s {
int __lock;
uint __count;
int __owner;
int __kind;
uint __nusers;
N15pthread_mutex_t17__pthread_mutex_s4__10E _BCD__1872;
}
union pthread_mutex_t {
__pthread_mutex_s __data;
char [24] __size;
int __align;
}
struct __locale_struct {
void * [13] __locales;
ushort * __ctype_b;
int * __ctype_tolower;
int * __ctype_toupper;
char * [13] __names;
}
struct RClass {
RBasic basic;
void * iv_tbl;
void * m_tbl;
uint _super;
}
struct _IO_FILE {
int _flags;
char * _IO_read_ptr;
char * _IO_read_end;
char * _IO_read_base;
char * _IO_write_base;
char * _IO_write_ptr;
char * _IO_write_end;
char * _IO_buf_base;
char * _IO_buf_end;
char * _IO_save_base;
char * _IO_backup_base;
char * _IO_save_end;
_IO_marker * _markers;
_IO_FILE * _chain;
int _fileno;
int _flags2;
int _old_offset;
ushort _cur_column;
char _vtable_offset;
char [1] _shortbuf;
void * _lock;
long _offset;
void * __pad1;
void * __pad2;
void * __pad3;
void * __pad4;
uint __pad5;
int _mode;
char [40] _unused2;
}
struct RBasic {
uint flags;
uint klass;
}
struct random_data {
int * fptr;
int * rptr;
int * state;
int rand_type;
int rand_deg;
int rand_sep;
int * end_ptr;
}
struct sched_param {
int __sched_priority;
}
struct timespec {
int tv_sec;
int tv_nsec;
}
struct N4wait3__0E {
uint __w_termsig;
uint __w_coredump;
uint __w_retcode;
uint _BCD__1903;
}
struct N4wait3__1E {
uint __w_stopval;
uint __w_stopsig;
uint _BCD__1906;
}
union wait {
int w_status;
N4wait3__0E __wait_terminated;
N4wait3__1E __wait_stopped;
}
struct RBignum {
RBasic basic;
char sign;
int len;
void * digits;
}
struct ldiv_t {
int quot;
int rem;
}
struct lldiv_t {
long quot;
long rem;
}
struct __fsid_t {
int [2] __val;
}
struct __sigset_t {
uint [32] __val;
}
struct fd_set {
int [32] fds_bits;
}
union pthread_attr_t {
char [36] __size;
int __align;
}
struct _IO_marker {
_IO_marker * _next;
_IO_FILE * _sbuf;
int _pos;
}
struct RFile {
RBasic basic;
void * fptr;
}
struct __pthread_cleanup_class {
}
union pthread_mutexattr_t {
char [4] __size;
int __align;
}
struct timezone {
int tz_minuteswest;
int tz_dsttime;
}
struct itimerval {
timeval it_interval;
timeval it_value;
}
union pthread_condattr_t {
char [4] __size;
int __align;
}
struct N16pthread_rwlock_t4__16E {
int __lock;
uint __nr_readers;
uint __readers_wakeup;
uint __writer_wakeup;
uint __nr_readers_queued;
uint __nr_writers_queued;
char __flags;
char __shared;
char __pad1;
char __pad2;
int __writer;
}
union pthread_rwlock_t {
N16pthread_rwlock_t4__16E __data;
char [32] __size;
int __align;
}
struct RObject {
RBasic basic;
void * iv_tbl;
}
union pthread_barrier_t {
char [20] __size;
int __align;
}
struct RHash {
RBasic basic;
void * tbl;
int iter_lev;
uint ifnone;
}
struct _G_fpos_t {
int __pos;
__mbstate_t __state;
}
struct _G_fpos64_t {
long __pos;
__mbstate_t __state;
}
struct RRegexp {
RBasic basic;
void * ptr;
int len;
char * str;
}
struct _pthread_cleanup_buffer {
_BCD_func__1707 __routine;
void * __arg;
int __canceltype;
_pthread_cleanup_buffer * __prev;
}
struct __sched_param {
int __sched_priority;
}
struct RData {
RBasic basic;
_BCD_func__1707 dmark;
_BCD_func__1707 dfree;
void * data;
}
struct N14pthread_cond_t4__13E {
int __lock;
uint __futex;
ulong __total_seq;
ulong __wakeup_seq;
ulong __woken_seq;
void * __mutex;
uint __nwaiters;
uint __broadcast_seq;
}
union pthread_cond_t {
N14pthread_cond_t4__13E __data;
char [48] __size;
long __align;
}
union pthread_rwlockattr_t {
char [8] __size;
int __align;
}
union pthread_barrierattr_t {
char [4] __size;
int __align;
}
struct __pthread_cleanup_frame {
_BCD_func__1707 __cancel_routine;
void * __cancel_arg;
int __do_it;
int __cancel_type;
}
union N11__mbstate_t4__21E {
uint __wch;
char [4] __wchb;
}
struct __mbstate_t {
int __count;
N11__mbstate_t4__21E __value;
}
struct _IO_cookie_io_functions_t {
_BCD_func__715 read;
_BCD_func__335 write;
_BCD_func__996 seek;
_BCD_func__256 close;
}
struct cpu_set_t {
uint [32] __bits;
}
/*struct N4__384__39E {
int [6] __cancel_jmp_buf;
int __mask_was_saved;
}
struct 4__38 {
N4__384__39E [1] __cancel_jmp_buf;
void * [4] __pad;
}*/
struct drand48_data {
ushort [3] __x;
ushort [3] __old_x;
ushort __c;
ushort __init;
ulong __a;
}
extern (C) extern uint rb_cMatch;
extern (C) extern uint rb_output_rs;
extern (C) extern uint rb_cUnboundMethod;
extern (C) extern uint rb_cRange;
extern (C) extern int ruby_sourceline;
extern (C) extern uint rb_cTrueClass;
extern (C) extern _IO_FILE * stderr;
extern (C) extern uint rb_eFloatDomainError;
extern (C) extern uint rb_stdin;
extern (C) extern uint rb_cFloat;
extern (C) extern uint rb_eNoMethodError;
extern (C) extern uint rb_cObject;
extern (C) extern int ruby_safe_level;
extern (C) extern uint rb_eLoadError;
extern (C) extern int __daylight;
extern (C) extern uint rb_mErrno;
extern (C) extern uint rb_eScriptError;
extern (C) extern uint rb_eNameError;
extern (C) extern uint rb_eSyntaxError;
extern (C) extern uint rb_eEOFError;
extern (C) extern char * [2] tzname;
extern (C) extern uint rb_cString;
//extern (C) extern void _IO_2_1_stdout_;
extern (C) extern uint rb_cFile;
extern (C) extern uint rb_cTime;
extern (C) extern uint rb_eStopIteration;
extern (C) extern uint rb_cEnumerator;
extern (C) extern uint rb_eRegexpError;
extern (C) extern uint rb_cNameErrorMesg;
extern (C) extern uint rb_eArgError;
extern (C) extern uint rb_mComparable;
extern (C) extern uint rb_cModule;
extern (C) extern uint rb_cRegexp;
extern (C) extern uint rb_cProc;
extern (C) extern uint rb_cFixnum;
extern (C) extern uint rb_eStandardError;
extern (C) extern char * [1] sys_errlist;
extern (C) extern uint rb_cFalseClass;
extern (C) extern uint rb_cData;
extern (C) extern int _sys_nerr;
extern (C) extern _IO_FILE * stdin;
extern (C) extern uint rb_eSignal;
extern (C) extern uint rb_eNotImpError;
extern (C) extern uint rb_cMethod;
//extern (C) extern void _IO_2_1_stderr_;
extern (C) extern uint rb_cArray;
//extern (C) extern void _IO_2_1_stdin_;
extern (C) extern uint rb_eSystemCallError;
extern (C) extern uint rb_cStruct;
extern (C) extern uint rb_eException;
extern (C) extern uint rb_eIndexError;
extern (C) extern uint rb_cNumeric;
extern (C) extern uint rb_cNilClass;
extern (C) extern char * [1] _sys_errlist;
extern (C) extern uint rb_mGC;
extern (C) extern uint rb_eLocalJumpError;
extern (C) extern uint rb_cClass;
extern (C) extern uint rb_mPrecision;
extern (C) extern uint rb_eSystemExit;
extern (C) extern uint rb_eNoMemError;
extern (C) extern uint rb_eIOError;
extern (C) extern uint rb_stdout;
extern (C) extern uint rb_argv0;
extern (C) extern uint rb_rs;
extern (C) extern uint rb_eFatal;
extern (C) extern uint rb_fs;
extern (C) extern char * [2] __tzname;
extern (C) extern void * ruby_current_node;
extern (C) extern uint rb_eTypeError;
//extern (C) extern int timezone;
extern (C) extern int getdate_err;
extern (C) extern int sys_nerr;
extern (C) extern int daylight;
extern (C) extern uint rb_mKernel;
extern (C) extern uint rb_stderr;
extern (C) extern uint rb_mFileTest;
extern (C) extern uint rb_cHash;
extern (C) extern uint rb_cSymbol;
extern (C) extern uint rb_eRuntimeError;
extern (C) extern uint rb_eRangeError;
extern (C) extern uint rb_cCont;
extern (C) extern uint rb_cIO;
extern (C) extern uint rb_cThread;
extern (C) extern int __timezone;
extern (C) extern uint rb_cInteger;
extern (C) extern uint rb_cBignum;
extern (C) extern uint rb_mMath;
extern (C) extern uint rb_cStat;
extern (C) extern _IO_FILE * stdout;
extern (C) extern uint rb_default_rs;
extern (C) extern uint rb_eSysStackError;
extern (C) extern uint rb_eSecurityError;
extern (C) extern uint ruby_verbose;
extern (C) extern char * ruby_sourcefile;
extern (C) extern uint rb_argv;
extern (C) extern uint rb_mEnumerable;
extern (C) extern uint ruby_debug;
extern (C) extern uint rb_cBinding;
extern (C) extern uint rb_mProcess;
extern (C) extern uint rb_output_fs;
extern (C) extern uint ruby_errinfo;
extern (C) extern int ruby_nerrs;
extern (C) extern uint rb_eZeroDivError;
extern (C) extern uint rb_eInterrupt;
extern (C) extern uint rb_eThreadError;
extern (C) extern uint rb_cDir;

/* special constants - i.e. non-zero and non-fixnum constants */
extern (C) const uint Qfalse = cast(VALUE)0;
extern (C) const uint Qtrue = cast(VALUE)2;
extern (C) const uint Qnil = cast(VALUE)4;
extern (C) const uint Qundef  = cast(VALUE)6;	/* undefined value for placeholder */